okay use the dropdown style
but to ensure only entrys on the list get used place in some auto search code ps maybe also a lil bit of validation
the code i use for the purpose is as follows
VB Code:
Private Sub comboBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbProdCat.KeyUp AutoComplete_KeyUp(comboBox1, e) End Sub Public Sub AutoComplete_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs) Dim sTypedText As String Dim iFoundIndex As Integer Dim sFoundText As String Dim sAppendText As String Select Case e.KeyCode 'allow select keys without auto completing Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down Return End Select 'get the typed text and find it in the list sTypedText = cbo.Text iFoundIndex = cbo.FindString(sTypedText) 'if the typed text is found then auto complete If iFoundIndex >= 0 Then sFoundText = cbo.Items(iFoundIndex) sAppendText = sFoundText.Substring(sTypedText.Length) cbo.Text = sTypedText & sAppendText cbo.SelectionStart = sTypedText.Length cbo.SelectionLength = sAppendText.Length Else cbo.SelectedIndex = 0 End If End Sub




Reply With Quote