Reputation: 7
I have a database (MS Access) connected to VB 2010. The search is a textbox and it is working, it filters what you typed in the text box but when I delete what I typed the datagrid goes blank. I want to show again in the datagrid all the records whenever I delete what I search.
Here is what I got so far.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged
BotikaBindingSource.Filter = "[Product name] = '" & txtsearch.Text & "'"
End Sub
Upvotes: 0
Views: 29
Reputation: 216343
If your Textbox is empty you need to call RemoveFilter for the BindingSource
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged
if string.IsNullOrWitheSpace(txtsearch.text) Then
BotikaBindingSource.RemoveFilter
else
BotikaBindingSource.Filter = "[Product name] = '" & txtsearch.Text & "'"
End If
End Sub
Upvotes: 1