3 Replies - 4968 Views - Last Post: 05 June 2015 - 03:47 PM Rate Topic: -----

#1 oljko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 20-May 15

How to show only selected rows from datagridview ?

Posted 05 June 2015 - 02:31 PM

Hi.

I have a datagridview and recently I got a task to add a checkbox column and a button which will filter/show only selected rows in datagridview so if I have for example 10 rows in datagrid, and I select 1st, 4th and 5th and click button datagrid should show only rows 1, 4 and 5. I've done my research, but unfortunately I cannot find solution and I think somehow the answer is rather simple. If anybody can help me I would be grateful.

Is This A Good Question/Topic? 0
  • +

Replies To: How to show only selected rows from datagridview ?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15490
  • View blog
  • Posts: 62,038
  • Joined: 12-June 08

Re: How to show only selected rows from datagridview ?

Posted 05 June 2015 - 02:35 PM

You would have your data in a DATASET not your grid. You would use the DATASET as the data source for a DataView. The DataView has a 'RowFilter' you can set to show only rows where a column is checked, specific text, etc.. then your DataGridView's data source is set to the data view.

Bingo!
Was This Post Helpful? 0
  • +
  • -

#3 oljko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 20-May 15

Re: How to show only selected rows from datagridview ?

Posted 05 June 2015 - 03:23 PM

View Postmodi123_1, on 05 June 2015 - 02:35 PM, said:

... The DataView has a 'RowFilter' you can set to show only rows where a column is checked ...


And how can I set that 'RowFilter' ? Thank you for your time.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15490
  • View blog
  • Posts: 62,038
  • Joined: 12-June 08

Re: How to show only selected rows from datagridview ?

Posted 05 June 2015 - 03:47 PM

Check the documentation.

https://msdn.microso...(v=vs.110).aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1