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