DataGridView, BindingList : Add and Remove

  • Thread starter Thread starter Claude
  • Start date Start date
C

Claude

It is possible to capture the "AddingNew" event to create our own object
before it is append to the BindingList (using e.NewObject = new ...)

When the user press delete on a row to remove a row from the DataGridView, I
need to do some stuff before it actualy modify the content of the
BindingList. Is it possible ? I tried to capture "List_Changed" event, but
it's too late, the object is already gone from the bindinglist !

What can I do ?

Thanks,
Claude
 
In this case, you can inherit from BindingList<T> and override the
RemoteItem method. You might also wish to consider SetItem (which is used by
the indexer "set").

class MyList<T> : BindingList<T>
{
protected override void RemoveItem(int index)
{
// do something fun and interesting to this[index]
base.RemoveItem(index);
}
}

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top