Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering a DataGridView 1

Status
Not open for further replies.

furjaw

Programmer
Mar 27, 2006
49
0
0
US
Visual Basic.Net:

I have a DataGridView in Last Name sequence.
Is it possible to when a user types the first letter of a last name
that it displays all rows with last names that start with that letter.
When he types the second letter, it displays all records whose last name starts with those 2 letters, etc.?
 
It is possible to have filter on DataSet.
Here is an example...
Code:
    Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
        Dim aFilter As String = ""

        '//Search name starts with
        aFilter = "LastName Like '" & txtSearch.Text & "*'"

        ' //To Search name contains..
        ' //Uncomment the next line
        'aFilter = "LastName Like '" & "*" & txtSearch.Text & "*'"


        '//Create the filter string.

        If txtSearch.Text.Trim = "" Then
            aFilter = ""
        Else
            aFilter = aFilter
        End If

        '//Apply the filter.
        ds_Northwind.Tables("Employees").DefaultView.RowFilter = aFilter

    End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
That worked just like I wanted it to!
THANKS!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top