Link to home
Create AccountLog in
Avatar of Millkind
MillkindFlag for Afghanistan

asked on

Filter a data grid with text boxes.

This code works, but i have several text boxes one for each column.  When you type into a new text box it reset the gridview.  How can i get the filter rows to stay when a new text box is typed into?

   Private Sub FILTER_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbtrackingnumber.KeyUp, tboriginator.KeyUp, tbboxnumber.KeyUp, tbcarrier.KeyUp, tbcarrierservice.KeyUp, tbfirstname.KeyUp, tblastname.KeyUp, tblocker.KeyUp, tbmiddlename.KeyUp, tbpackagetype.KeyUp, tbsubbox.KeyUp
        Try
            If tbtrackingnumber.Text.Length > 0 Then
                Dim bsfindapackage As New BindingSource
                bsfindapackage.DataSource = dvfindapackage
                dgfindapackage.DataSource = bsfindapackage
                bsfindapackage.Filter = "([" & sender.tag & "] like '*" & sender.Text & "*')"
            End If
        Catch ex As Exception
            mainform.errorwrite(ex.ToString & " tracking number key up")
        End Try
    End Sub
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer