DataGrid Filter

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi all,
I have a DataTable and a DataGridView that is using it as a datasource.
I'm using the DataTable.Select method and I can find some rows. Is it now
possible, somehow to use the result of the Select method (a DataRow
collection) to make the DataGridView filtering only on those rows? I mean to
display only the found rows and after that to select all previous rows back
again? I want to use two buttons on my form "Apply Filter" and "Clear
Filter" to accomplish this.

Thanks for your time.
Paul
 
This can much simpler ( if you program on framework 2 or higher )

Instead of using the select method on the datatable you would better create
a dataview object perform the filter on this object and bind this to the
datagridview
if you want to remove the filter well then you just rebind the original
datatable

HTH

Michel
 
Thank you very much Michel for your answer. I'm already using Framework 2.
Actually I found a different (and much flexible for my oppinion) approach
for this thing, using the BindingSource class as a datasource instead of the
datatable for my DataGridView object. Thus, all I have to do is to apply my
filter in BindingSource.Filter property and using the RemoveFilter method to
remove it.



Thanks again and have a nice day.

Paul
 
Back
Top