I have a combobox. I want to select the item in the combobox when the text is entered (not matching just the first letter) and
the user presses enter key. Please suggest!
Printable View
I have a combobox. I want to select the item in the combobox when the text is entered (not matching just the first letter) and
the user presses enter key. Please suggest!
are you talking about finding the exact string and selecting it then? if so...
VB Code:
[Color=Blue]Private[/COLOR] [Color=Blue]Sub[/COLOR] ComboBox1_KeyUp([Color=Blue]ByVal[/COLOR] sender [Color=Blue]As[/COLOR] [Color=Blue]Object[/COLOR], [Color=Blue]ByVal[/COLOR] e [Color=Blue]As[/COLOR] System.Windows.Forms.KeyEventArgs) [Color=Blue]Handles[/COLOR] ComboBox1.KeyUp [Color=Blue]If[/COLOR] e.KeyValue = Keys.Enter [Color=Blue]Then [/COLOR] [Color=Blue]Dim[/COLOR] x [Color=Blue]As[/COLOR] [Color=Blue]Integer[/COLOR] = ComboBox1.FindStringExact(ComboBox1.Text) ComboBox1.SelectedIndex = x [Color=Blue]End[/COLOR] [Color=Blue]If [/COLOR] [Color=Blue]End[/COLOR] [Color=Blue]Sub[/COLOR]
thanks works great, but I would rather replace FindStringExact with FindString
you can use FindString also to find the whole word ( but also to find the string by it's first character / characters )