Textbox Listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have textbox and listbox on my form . Listbox has data. When user key in
the data in textbox closest item in listbox should get selected. (like
keypress in listbox) .How to achieve this
Thanks in advance
Sudheendra
 
Sudhee,

You should use ListBox's FindString or FindStringExact methodos. In your
case I believe you need the FindString method.
 
Hi,
Thanks, This works only problem I am facing is when I type in textbox first
letter ,the focus will always go to the first item in the list box ,only
after I enter second letter it will search for the first letter for example
I have
Apple
Orange
Guava
Banana

If I type O in text box it will first focus Apple and on keying r it will
focus orange. Always goes to the first item. is there anyway to overcome this.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

Me.ListBox1.SelectedIndex = Me.ListBox1.FindString(Me.TextBox1.Text)
End Sub
Thanks
Sudhee
 
Back
Top