IndexOf on bound ComboBox not working??

  • Thread starter Thread starter Rob R. Ainscough
  • Start date Start date
R

Rob R. Ainscough

I know I must be going crazy, but for the life of me I can't figure out why
IndexOf is always returning -1?

With MyComboBox
.ValueMember = "Field1"
.DisplayMember = "Field2"
.DataSource = SomeDataTable
End With

MyIndex = MyComboBox.Items.IndexOf("myValue")

MyIndex is always -1, it never finds the value even though I've stepped thru
the Items and validated that "myValue" exists.

What am I missing?

Thanks, Rob.
 
Hi Cor,

I've had to use those methods, but they are not accurate enough for me. The
valueMember ensures uniqueness as the DisplayMember could show duplicate --
i.e. ValueMember = CustomerAccount and DisplayMember = Customer Last
Name -- there could be and most likely will be customers with the same last
name (and/or same first & last name). Using the FindString and
FindStringExact would find the first matching customer which may or may not
be the actual customer I want.

But why does IndexOf not work with data bound ComboBox?

Rob
 
Back
Top