Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

 

I've got a ListBox, TextBox and a Button. I'm searching the ListBox like in the code below:

 

   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. Isn't it possible to use some sort of wildcards so I can, for example, find the item 'Theo' by only giving 'Th'?

 

Thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...