Sudhee,
You should use ListBox's FindString or FindStringExact methodos. In your
case I believe you need the FindString method.

Signature
HTH
Stoitcho Goutsev (100)
> 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 - 15 Feb 2006 15:21 GMT
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
> Sudhee,
>
[quoted text clipped - 7 lines]
> > Thanks in advance
> > Sudheendra