Hi Im having a problem in my search..

I have a listbox named listbox1 then a button beside a textbox for searching records inserted inside the listbox..

but when I dont type anything, the listview items gone..,

what is the best way to solve this? :)

Thanks

Recommended Answers

All 4 Replies

See if this helps :

Private Sub FindMySpecificString(ByVal searchString As String)
    ' Ensure we have a proper string to search for.'
    If searchString <> String.Empty Then
        ' Find the item in the list and store the index to the item.'
        Dim index As Integer = listBox1.FindStringExact(searchString)
        ' Determine if a valid index is returned. Select the item if it is valid.'
        If index <> ListBox.NoMatches Then
            listBox1.SetSelected(index, True)
        Else
            MessageBox.Show("The search string did not find any items in the ListBox that exactly match the specified search string")
        End If
    End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    FindMySpecificString(TextBox1.Text)
End Sub

One you say listBox, and ones listView? What is it gonna be?

but when I dont type anything, the listview items gone..,

What is thill suppose to mean?

oh sorry listview means listbox.., I typed it wrong :)

Dim abc As String
    abc = TextBox4.Text
    If abc = "" Then
        MsgBox("Empty")
    Else
        If ListBox1.FindString(abc) <> True Then
            MsgBox("Got it")
        Else
            MsgBox("Not")
        End If
    End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.