hello guys

I have a data grid view with the following rows customerID, customerName, credit, debt. how do I implement filtering based on the customerID. I want to basically perform a search and display the results.


Where are your customer records - are they in a database?

Also this is WinForms right?

my records are in an access database. this is windows form. the data source of the data grid view is an access dataset

Ok so first question is how to users choose which id to search on - is that typed into a textbox maybe?

Sorry my previous post has a typo in which may make it unclear.

It should read

"Ok so first question is how do users choose which id to search on - is that typed into a textbox maybe?" - ie do instead of to

In case you didn't know, you can edit a post within 30 minutes of submitting it.

the ID is to be typed in a text box.

Yep I often edit but couldn't this time so the 30 minutes must have passed :(

BindingSource is your friend:

private BindingSource _bs = new BindingSource();


// Initialize DGV
_bs.DataSource = ds.Tables("Customer");
dataGridViewCustomers.DataSource = _bs;


// Filter DGV
_bs.Filter = string.Format("customerID LIKE '%{0}%'", customerID);

thanks a lot for the idea. I used it and it worked though I incorporated it in the text change. but, I have another question. how do I refresh the data grid view after filtering? because with this technique, in case the data is not found the data grid view is empty but I want it to be refreshed so that a search can be performed again and if I select the filtered row I want the data grid view to also be refreshed.

I got a solution. I used RemoveFilter in the button click.