Theo
Member
Hi all,
Ive got a ListBox, TextBox and a Button. Im searching the ListBox like in the code below:
But now it will only work if you give the full text of an item. Isnt it possible to use some sort of wildcards so I can, for example, find the item Theo by only giving Th?
Thanks
Ive got a ListBox, TextBox and a Button. Im searching the ListBox like in the code below:
Code:
Private Sub btnZoeken_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoeken.Click
Dim lbItem As ListItem
Dim strFind As String = txtZoeken.Text
Dim strFirst As String
Dim strRest As String
If strFind <> "" Then
Change the first character into UpperCase and the rest into LowerCase.
strFirst = strFind.Substring(0, 1)
strRest = strFind.Substring(1)
strFind = strFirst.ToUpper() + strRest.ToLower
lbItem = lbWerknemers.Items.FindByText(strFind)
If IsNothing(lbItem) Then Exit Sub
Make sure that the found item is selected.
lbWerknemers.SelectedValue = lbItem.Value
End If
End Sub
But now it will only work if you give the full text of an item. Isnt it possible to use some sort of wildcards so I can, for example, find the item Theo by only giving Th?
Thanks