Combo Box in Vb.Net
I have one combobox in my form in vb.net 2005. In that combobox I am adding all Personnames from database using form1_load event.
Now the problem is,
If I type some character in combobox then it should check the entire data in database or combobox and the data should be sorted out according to the character which i typed.I had tried the following code:
Private Sub cboPersonname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cboPersonname.KeyPress
Dim strName As String
Dim intIdx As Integer
strName = cboPersonname.Text
cboPersonname.Items.Clear()
strQuery = "Select * from Customer where Personname like '" & strName & "%' "
db.opentable(strQuery)
For intIdx = 1 To db.dtable.Rows.Count - 1
cboPersonname.Items.Add(New DataDescription(db.dtable.Rows(intIdx).Item("Compn o"), db.dtable.Rows(intIdx).Item("Personname")))
Next
End Sub
The following problem is occuring in my code:
If I type the first character for example consider 'a', then the value passing to the variable strName = "".
If I type the first character for example consider 'ab', then the value passing to the variable strName = a. After this the data are sorted with the string "a" only. not with "ab"
If I type the first character for example consider 'aba', then the value passing to the variable strName = ba. After this the data are sorted with the string "ba" only. not with "aba"
Query and Databaseconnection and Loading Personname with its id are working proerly.Only thing Sorting of data.
That is the combo box ommitted the first character.How can I overcome the Problem?

