I'm showing database records through a DataGridView in a WinForms application. Also , i have a textview , a combobox and a datetimepicker. How can i sort the datagridview to show only records which equals the textview or the combobox or datetimepicker?
2
votes
1 Answers
2
votes
Description
You need the BindingSource
between your, for example, DataSet
and your DataGridView
.
With a BindingSource you are able to filter your DataSource because the BindingSource has a .Filter
property.
If you change the filter, it will filter your DataGridView
too.
BindingSource.Filter Gets or sets the expression used to filter which rows are viewed.
Sample
Add the BindingSource from the ToolBox, this is only a sample
BindingSource myBindingSource = new BindingSource();
myBindingSource.DataSource = myDataTable;
myDataGridView.DataSource = myBindingSource;
myBindingSource.Filter =// your filter