Hello all,
I have numerous combo boxes in my program where users can type in and as they are typing the closest match appears. The problem is that once the first key is pressed and a match is found by the FindString method, that is what the program holds onto, even if that is not what is finally choosen. This only happens if you type in till the correct item appears and the tab out, yet if they click on the item then that item is correctly remembered.
How do I fix this problem so that the correct item is remembered through typing only.
Here is the code I am using that is causing the problem :
Any help, as always, is greatly appreciated.
Brian
I have numerous combo boxes in my program where users can type in and as they are typing the closest match appears. The problem is that once the first key is pressed and a match is found by the FindString method, that is what the program holds onto, even if that is not what is finally choosen. This only happens if you type in till the correct item appears and the tab out, yet if they click on the item then that item is correctly remembered.
How do I fix this problem so that the correct item is remembered through typing only.
Here is the code I am using that is causing the problem :
Code:
Try
Select Case e.KeyCode
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down, Keys.Home, Keys.End
Return
End Select
strEntry = cboUserName.Text
intFoundIndex = cboUserName.FindString(strEntry)
If intFoundIndex >= 0 Then
cboUserName.DroppedDown = True
objFoundItem = cboUserName.Items(intFoundIndex)
strFoundText = cboUserName.GetItemText(objFoundItem)
strAppendText = strFoundText.Substring(strEntry.Length)
cboUserName.Text = strEntry & strAppendText
cboUserName.SelectionStart = strEntry.Length
cboUserName.SelectionLength = strAppendText.Length
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Information")
End Try
Any help, as always, is greatly appreciated.
Brian