Question Problem with ComboBox - SelectedValue <> SelectedItem

joefa

Member
Joined
Sep 16, 2010
Messages
19
Programming Experience
5-10
Hi,

Strange issue with the .Net Combobox - the SelectedValue is disagreeing with the SelectedItem.

[XCODE]
Dim VATCategoryAdapter As New IClarityDataSetTableAdapters.VATCategoryTableAdapter
Dim newVATCategoryTable As New IClarityDataSet.VATCategoryDataTable
.
.
newVATCategoryTable.DefaultView.Sort = "VATType, VATValue"
.
.
VATCategoryAdapter.Fill(newVATCategoryTable)
cmbNewVATCategory.DisplayMember = "VATDescription"
cmbNewVATCategory.ValueMember = "VATCategoryID"
cmbNewVATCategory.DataSource = newVATCategoryTable.DefaultView
[/XCODE]

Because the ValueMember is set to the data field called "VATCategoryID", I would expect it to be always the same as the property called "VATCategoryID" of the typed DataRow which is currently the SelectedItem. But it isn't always - I can put a breakpoint in the code after a value is selected from the ComboBox, and these values are often different.

In the data I am testing with, there are 120 rows in the table, and it's often out by about 2 or 3 rows, e.g. if the display is showing the user-friendly text ("VATDescription") for the 50th row, the SelectedValue will probably be the VATCategoryID for the 52nd or 53rd row.

This is driving me nuts. Any ideas what could be wrong?

Thanks
Joe
 
Back
Top