Find out the changed rows in DataGridView

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a DataGridView.
It's data source is a collection of objects (not a DB records).

After the user did some changes (Add/Delete/Update) I want to find out the
changed rows and the action made on them.

How to do it?


10x
 
Typically you will maintain this state inside of your custom objects. Add
and Update can be maintained with an internal IsNew and IsDirty flags.
Delete is a bit trickier as your object will have to tell it's collection to
flag it for deletion. When you are ready to persist your information, your
collection then will need to have the CRUD functions to persist the objects
based on their information.

Create: IsNew=True
Update: IsDirty and not IsNew
Delete: IsDeleted (in a deleted collection inside the hosting
collection?)

The downside of objects is that you have to do some of the plumbing
yourself. The upside is you get to do some of the plumbing yourself.

Jim
MCSD.Net
 
Would it be easier if I create a DataTable from my object collection, bind it
to the DataGridView, and by that have all the "flags/state management" for
free?

Regards,
Moshe
 
Back
Top