0

Hi people, I have created a form that allows me to search customers from a datagrid table which holds the information from the customers table. I use a textbox to enter the phrase to search for and a search button. I can find the records within the datagrid table but it only selects them. I want the datagrid to only display the records found. How I achieve this ?

If RadioButtonName.Checked = True Then
            Me.CustomersTableAdapter.Fill(Me.NorthwindDataSetCustomers.Customers)
            For Each CurrentRow As DataGridViewRow In DataGridView1.Rows
                If CurrentRow.Cells(2).Value.ToString.Contains(TextBoxSearch.Text) Then
                    CurrentRow.Selected = True
               
                End If
            Next
        End If

The code above finds the customers name but it only selects their detials on the datagrid table and i only want those rows found to only be displayed on the datagrid. Can anyone please help?

Thanks!

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Pgmer
0

In search create table and add the records to new table and then assign that new table to grid as source.

0

Use the .Select method and set the resulting array of Datarows to be the datasource of your grid

Edited by Ranx: typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.