User of ComboBox in VB.NET

jimreidjimreid Williamstown, NJ
edited August 2014 in Beginner VB

Don't know if anyone can help with this or not. I have a combo box that has a datasource which loads a table that the displaymember is a description and the valuemember is a code (not an index of the combobox). I'm trying to figure out how to set the selectedindex to the entry that has the valuemember equal to an external value (from a file). It appears that when I compare the external field to the value member it doesn't match. When I check the valuemember it appears to be the name of the field that should be loaded on initiation. I thought that the combo was loaded with the initial statement that is generated with the tableadapter.fill statement but can't tell if the correct fields are loaded in the combobox.

I've looked high and low and can't find out how to display what is loaded in the valuemember field, I thought that you should be able to index through it like an array but that doesn't seem to work.

Somewhere I read that to get to the right entry in the combo, I should loop through the combobox until the value member equals my external that I'm trying to match to and then set the selectedindex to the looping subscript. But that doesn't seem to work either. I can post the code but I think this is pretty clear.

  1. combobox is loaded (with table adapter fill statement)
  2. read an external record with combo valuemember in it as data1.
  3. set selectedindex to the entry that has the valuemember equal to data1.
  4. if operator selects a different entry:
    a. update data1 with valuemember of selected item.

Any help would be appreciated.



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!