When we use IE or Access, we must pay attention to this very interesting thing: Enter text box controls can help us to automatically add the content we want to enter by matching our past. It is very convenient. However, in our programming, this fancy function is not packaged in the control. In fact, you have to teach them to do this, not difficult, 淌 淌 控 控 (because ComboBox is used to do this example, it is faded, give you a very simple code. Other text input controls are also the same truth, I haven't described it. Private sub comboBOX1_KEYUP (Byval e as system.windows.forms.keyeventargs) Handles ComboBox1.Keyup AutoCompleteKeyup (ComboBoX1, E) End Sub
Public Sub AutoCompleteKeyUp (ByVal Combo As ComboBox, ByVal e As KeyEventArgs) Dim strTyped As String Dim intFoundIndex As Integer Dim objFoundItem As Object Dim strFoundText As String Dim strAppendText As String 'ignore the basic operation keys Select Case e.KeyCode Case Keys.Back, Keys.left, Keys.right, Keys.up, _ keys.delete, keys.down, keys.capslock return end select 'See what users entering strtyped = combo.text intFoundIndex = Combo.FindString (strtyped) found, then ...... if intFoundIndex> = 0 then 'Get under matches Combo objFoundItem = Combo.Items (intFoundIndex)' for a matching string strFoundText = Combo.GetItemText (objFoundItem) 'starts automatically add text strAppendText = strFoundText.Substring (strtyped.Length) Combo.Text = Strtyped & StrappendText 'Select the added text Combo.SelectionStart = Strtyped.Length Combo.SerectionLength = ST RappendText.Length End If End Sub is fine, you can try the code above. Let's put some strings in the ComboBox drop-down list, hehe!