I am scratching around with 2 problems. THe first - I am trying to fill a listbox dynamically as a textbox is filled, the result filling a listbox with the field having matches in view and the record ID in a column with width set to zero. Can someone guide me how to do it, or point me in the right direction.
The other is how do I cycle through a filled listbox against a users texbox entry until there is a complete match or nothing found. I tried some code but it did not do anything. I added an extra line in the code which set the listindex so I could see it running through the list. The list itself has a leading hidden column with an ID number which I use to select the record from the list. The second column on view is a barcode number. I tried entering both Barcode number and record number into the textbox but it just went passed the record in the listbox each time.
I tried an alternative method to retrieve the second item in the listbox so that I could see what it was looking for in search with:
Dim PJ As String = ListBox1.SelectedItem.ToString
MsgBox(PJ)but it did not work.
Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox11.TextChanged
Me.ListBox1.SelectedItems.Clear()
If Not TextBox11.Text.Trim = "" Then
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox1.SelectedIndex = i
If ListBox1.Items(i).ToString.StartsWith(TextBox11.Text.Trim) Then
ListBox1.SelectedItems.Add(ListBox1.Items(i))
Exit For
End If
Next
End If
End Sub
Any help very much appreciated
The other is how do I cycle through a filled listbox against a users texbox entry until there is a complete match or nothing found. I tried some code but it did not do anything. I added an extra line in the code which set the listindex so I could see it running through the list. The list itself has a leading hidden column with an ID number which I use to select the record from the list. The second column on view is a barcode number. I tried entering both Barcode number and record number into the textbox but it just went passed the record in the listbox each time.
I tried an alternative method to retrieve the second item in the listbox so that I could see what it was looking for in search with:
Dim PJ As String = ListBox1.SelectedItem.ToString
MsgBox(PJ)but it did not work.
Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox11.TextChanged
Me.ListBox1.SelectedItems.Clear()
If Not TextBox11.Text.Trim = "" Then
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox1.SelectedIndex = i
If ListBox1.Items(i).ToString.StartsWith(TextBox11.Text.Trim) Then
ListBox1.SelectedItems.Add(ListBox1.Items(i))
Exit For
End If
Next
End If
End Sub
Any help very much appreciated