ComboBox - Search and Select
[Originally posted by L_Cotten]
I have a combobox who's style is set to DropDownList.ÿ I want to search the list for an item with certain text and then select that item.ÿ How would I go about doing that??
Thanks for your help.ÿ :-)
Re:ComboBox - Search and Select
[Originally posted by Torgrim Brochmann]
Use the items-collection of the combobox.ÿ When you create a combo in Visual Basic, you have the option of adding indexes to all of your entries as the second parameter of the add-method (as long as you're not directly loading from a database, that is).ÿ This index is zero-based, which means that you can loop trough the combo using this index from 0 to the combos items.count-method.
Say you do something like:
'MyCombo is the combobox
Dim i as Integer
Dim ReturnValues(MyCombo.Index.Count) as Integer
For i = 0 to MyCombo.Items.count - 1
ReturnValues(i) = MyCombo.Index(i).Value
What you also could do was to load all the values in to an array as you read them into the combobox, and then read from the array instead of reading form the combobox, as this would make your code faster, more efficient and easier to read and maintain.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center