Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox selectedtext command not working correctly 1

Status
Not open for further replies.

hayt

IS-IT--Management
Oct 5, 2004
132
US
I am having an issue with a combo box. I have a list of strings set from a lookup table, and i set the combobox's selectedtext at runtime. the problem is, that the box dispays the selectedtext concatenated with the first item in the list. any ideas????
 
i am pulling data from my dataset, and setting the combobox to that, but i guess i could always setup a switch, just seems like there would be an easier way.
 
i've tried indexOf, and i cannot get it to take the string, it keeps returning nothing in the combobox. am i using the command correctly? indexOf(string)? what is the argument?
 
It's because the combobox will not contain string objects when bound to a dataset. It will contain DataRowViews. Therefore, you must not be using the DropDownList style. You must be using the type of ComboBox that allows users to type what they want in the box--even if it is not in the list.

I'm sure there may be easier ways, but try this:

Code:
For Each drv As DataRowView In ComboBox.Items
     If drv.Item(0) = "Your value you need" Then
          ComboBox.SelectedItem = drv
          Exit For
     End If
Next
 
i figured it out just before you posted. thanks soo much, i got stupid there for a second.

cboCOMBOBOX.SelectedIndex = cboCOMBOBOX.FindString(datarow.Item("FIELD").ToString)

This works great! thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top