By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,575 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,575 IT Pros & Developers. It's quick & easy.

DataGrid Filter

P: n/a
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

Sep 22 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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


"Paul" <pg*********@yahoo.grschreef in bericht
news:BE**********************************@microsof t.com...
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

Sep 22 '07 #2

P: n/a

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

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:OB*************@TK2MSFTNGP06.phx.gbl...
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


"Paul" <pg*********@yahoo.grschreef in bericht
news:BE**********************************@microsof t.com...
>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

Sep 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.