Rob
Rob

Reputation: 1539

Updating datagridview and saving into new dataset

I'm not sure if this is the right approach but I have a datagridview that is binded to a dataset that displays all saved tasks. I then have filter options that allow the user to filter out tasks that do match match the date range they select.

At the moment im using the visible property for the rows that do not match the date range which is sucessfully hiding the rows.

However, I have a print feature that is supposed to print out the tasks that remain in the datagridview, not the hidden ones. The problem is that the print event is linked to the original dataset so it is printing out all the tasks.

What I want to do is somehow put the remaining DGV rows into a new dataset and then link that dataset to the print event so only the filtered tasks are printed.

Does anyone know the easiest way of achieving this?

Code examples would be great!

Thankyou

Upvotes: 0

Views: 436

Answers (1)

Shrieks
Shrieks

Reputation: 141

You might be better off filtering the dataset itself, thus you dont have to 'hide' the rows and the print feature would also work.

If you want to persist with this, then look at dataset.Clone:

DataSet cloneSet = dataSet.Clone();

Then iterate over the GridView rows and filter out the hidden rows when adding to the cloned dataset and pass that off for printing.

Upvotes: 1

Related Questions