I have a simple Windows Forms screen with several combo boxes filled with data tables contained in a non-typed dataset, that is populated from SQL Server. I will load this form, passing a data table in as an argument for the row to edit. The goal is to have the combos reflect (data binding) the values in the data row.
'Declarations
Dim WithEvents bs As New BindingSource
Dim _MasterDS As DataSet
Dim dt As DataTable '(Incoming data for updating)
-------------------------------------------------------
Sub New(_dt as datatable)
dt = _dt
bs.DataSource = dt
End sub
'Fill _Master_DS
'Initially Fill the Combobox with Product choices
With CmboProduct
.DataSource = _MasterDS.Tables("Products")
.ValueMember = "ProductID"
.DisplayMember = "Product"
.SelectedItem = Nothing
End With
Sub Bindem
txtComments.DataBindings.Add("Text", bs, "Comments")
dtpEntryDate.DataBindings.Add("Value", bs, "EntryDt")
CmboProduct.DataBindings.Add(New Binding("SelectedValue", bs, "ProductID"))
'etc
End SubThe issue is CmboProduct does not reflect the incoming rows value, its displays nothing. I'm betting its a data type issue, because if I simply send a command below ... it populates fine
CmboProduct.SelectedValue = CShort(dt.Rows(0).Item("ProductID"))I appreciate any feedback.. I cannot be the only one stumped on this.
Paul J. Ilacqua