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.

thanks.

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

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.
thanks

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

thanks.

This article has been dead for over six months. Start a new discussion instead.