este es mi código que tengo para autocompletar es
Código:
y con este, cargo mi combobox:Private Sub cmb_nacionalidad_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmb_nacionalidad.KeyUp Dim sTypedText As String Dim iFoundIndex As Integer Dim oFoundItem As Object Dim sFoundText As String Dim sAppendText As String 'Allow select keys without Autocompleting Select Case e.KeyCode 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 = Trim(Me.cmb_nacionalidad.Text) iFoundIndex = Trim(Me.cmb_nacionalidad.FindString(sTypedText)) 'If we found the Typed Text in the list then Autocomplete If iFoundIndex >= 0 Then 'Get the Item from the list (Return Type depends if Datasource was bound ' or List Created) oFoundItem = Me.cmb_nacionalidad.Items(iFoundIndex) 'Use the ListControl.GetItemText to resolve the Name in case the Combo ' was Data bound sFoundText = Me.cmb_nacionalidad.GetItemText(oFoundItem) 'Append then found text to the typed text to preserve case sAppendText = sFoundText.Substring(sTypedText.Length) Me.cmb_nacionalidad.Text = sTypedText & sAppendText 'Select the Appended Text Me.cmb_nacionalidad.SelectionStart = sTypedText.Length Me.cmb_nacionalidad.SelectionLength = sAppendText.Length End If End Sub Private Sub cmb_nacionalidad_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_nacionalidad.Leave Dim iFoundIndex As Integer iFoundIndex = Me.cmb_nacionalidad.FindStringExact(Me.cmb_nacionalidad.Text) Me.cmb_nacionalidad.SelectedIndex = iFoundIndex End Sub
Código:
gracias por la colaboración. Da = New OleDb.OleDbDataAdapter("SELECT adgrlsubg, adgrldesc FROM adgrl " & _ " WHERE (adgrlgrup = 9) " & _ " AND (adgrlsubg > 0) " & _ " ORDER BY adgrlsubg", con.cnn) Da.Fill(Ds4, "adgrl") Me.cmb_nacionalidad.DataSource = Ds4.Tables("adgrl") Me.cmb_nacionalidad.DisplayMember = "adgrldesc" Me.cmb_nacionalidad.ValueMember = "adgrlsubg"