در ضمن من این کد ها رو از اینترنت برداشتم کمی هم اصلاحش کردم کار می کنه اما یه اشکال داره ببینین میتونین رفعش
PublicSharedSub AutoComplete(ByVal combobox1 As ComboBox, _
ByVal e As System.Windows.Forms.KeyEventArgs)
' Call this from your form passing in the name
' of your combobox and the event arg:
' AutoComplete(cboState, e)
Dim iIndex AsInteger = 0
Dim sActual AsString
Dim sFound AsString
Dim bMatchFound AsBoolean
'check if the text is blank or not, if not then only proceed
IfNot combobox1.Text = "" Then'if the text is not blank then only proceed
' If backspace then remove the last character
' that was typed in and try to find
' a match. note that the selected text from the
' last character typed in to the
' end of the combo text field will also be deleted.
If e.KeyCode = Keys.Back Then
combobox1.Text = Mid(combobox1.Text, 1, Len(combobox1.Text) - 1)
EndIf
' Do nothing for some keys such as navigation keys...
If ((e.KeyCode = Keys.Left) Or _
(e.KeyCode = Keys.Right) Or _
(e.KeyCode = Keys.Up) Or _
(e.KeyCode = Keys.Down) Or _
(e.KeyCode = Keys.PageUp) Or _
(e.KeyCode = Keys.PageDown) Or _
(e.KeyCode = Keys.Home) Or _
(e.KeyCode = Keys.End) Or _
(e.KeyCode = Keys.Enter)) Then
Return
EndIf
Do
combobox1.DroppedDown = True
' Store the actual text that has been typed.
sActual = combobox1.Text
' Find the first match for the typed value.
iIndex = combobox1.FindString(sActual)
' Get the text of the first match.
' if index > -1 then a match was found.
If (iIndex > -1) Then'** FOUND SECTION **
'combobox1.Text = ""
sFound = combobox1.Items(iIndex).ToString()
' Select this item from the list.
combobox1.SelectedIndex = iIndex
' Select the portion of the text that was automatically
' added so that additional typing will replace it.
'combobox1.SelectionStart = sActual.Length
'combobox1.SelectionLength = sFound.Length
bMatchFound = True
Else'** NOT FOUND SECTION **
'if there isn't a match and the text typed in is only 1 character
'or nothing then just select the first entry in the combo box.
If sActual.Length = 1 Or sActual.Length = 0 Then
combobox1.SelectedIndex = 0
combobox1.SelectionStart = 0
combobox1.SelectionLength = Len(combobox1.Text)
bMatchFound = True
Else
'if there isn't a match for the text typed in then
'remove the last character of the text typed in
'and try to find a match.
'************************** NOTE **************************
'COMMENT THE FOLLOWING THREE LINES AND UNCOMMENT
'THE (bMatchFound = True) LINE
'INCASE YOU WANT TO ALLOW TEXTS TO BE TYPED IN
' WHICH ARE NOT IN THE LIST. ELSE IF
'YOU WANT TO RESTRICT THE USER TO TYPE TEXTS WHICH ARE
'NOT IN THE LIST THEN LEAVE THE FOLLOWING THREE LINES AS IT IS
'AND COMMENT THE (bMatchFound = True) LINE.
'************************************************* **********
'/////// THREE LINES SECTION STARTS HERE ///////////
combobox1.SelectionStart = sActual.Length - 1
combobox1.SelectionLength = sActual.Length - 1
combobox1.Text = Mid(combobox1.Text, 1, Len(combobox1.Text) - 1)
'/////// THREE LINES SECTION ENDS HERE /////////////
'bMatchFound = True
EndIf
EndIf
LoopUntil bMatchFound
EndIf
EndSub
کنین