How do I save changes to my datasource when swapping datasources out of my DGV?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How do I save changes to my datasource when swapping datasources out of my DGV?

I have two datasources that i switch out of my datagridview, but when i change between the two the changes i've made to either one are not saved... How do I accomplish such? For example, I change the forcolor of certain rows in one datasource and when i swap back and forth the color is back to default.

Re: How do I save changes to my datasource when swapping datasources out of my DGV?

It's not that the colour is back to the default. It's that changing the data source causes all the existing rows to be removed and new ones added. You've never set those new rows to anything other than the default colour so why would they be anything but the default colour? This is why it's best to use events of the grid to do formatting like this. That way, it doesn't matter what changes you make to the grid as all the correct formatting will be reapplied dynamically.

Re: How do I save changes to my datasource when swapping datasources out of my DGV?

I am periodically changing certain rows to the color red, as well as selecting them in a checkbox column. I should elaborate on this. The records in my DGV will be manipulated based off a search criteria I have built in another form. This will lead to the rows changing in a variety of ways up to and including what I have previously described (color, checkboxcolumn, etc.)

Re: How do I save changes to my datasource when swapping datasources out of my DGV?

You will need to either build a list of criteria that a row must match in order to be highlighted and then process those criteria on the appropriate event of the grid, which ensures that all matching rows will always be highlighted no matter what else you do, or else you'll need to process the new rows that get added to highlight those that need it after resetting the data source.