I want to put a search option in DataGridView
, i.e., User types the string or int in TextBox
and similar records the DataGridView
shou
If your DataGridView is bound to a DataTable or a DataView, you can do this:
Create a BindingSource and make BindingSource.DataSource
the Datatable or DataView that your DGV is currently using. Then set your DataGridView.DataSource
to the BindingSource. Then you can use the BindingSource.Filter
property to query your datasource by setting the BindingSource.Filter
to your query string which will automatically filter the DGV. You can find the syntax here - it is very similar to basic SQL queries, except you can only use wild cards on the beginning and end of the string.