Need for BindingSource.Removing event

J

jehugaleahsa

Hello:

I have a BindingSource that has its DataSource set to a
BindingList<Customer> where Customer is a business object that
manipulates a DataRow. All changes to a Customer instance, update a
DataTable via DataRow.

It is fairly easy to add a new item to the BindingSource. However,
removing is a different story. I need to be able to know when an item
is removed because I would like to call Delete on the DataRow. I need
to be able to access the item being removed and do it there.

However, the best thing available is ListChanged, and it is pretty
useless for what I am doing. I suppose I could inherit from
BindingSource and overload the methods and add an event.

Is this the way to go? or is there something built in?

~Travis
 
N

Nicholas Paldino [.NET/C# MVP]

Travis,

Unfortunately, the BindingList doesn't have a ListChanging event.
Personally, I would derive a class from BindingList<T> and then override the
RemoveItem method to fire a ListChanging event, which is fired before the
item is removed from the list.
 
J

jehugaleahsa

Travis,

Unfortunately, the BindingList doesn't have a ListChanging event.
Personally, I would derive a class from BindingList<T> and then override the
RemoveItem method to fire a ListChanging event, which is fired before the
item is removed from the list.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I have a BindingSource that has its DataSource set to a
BindingList<Customer> where Customer is a business object that
manipulates a DataRow. All changes to a Customer instance, update a
DataTable via DataRow.
It is fairly easy to add a new item to the BindingSource. However,
removing is a different story. I need to be able to know when an item
is removed because I would like to call Delete on the DataRow. I need
to be able to access the item being removed and do it there.
However, the best thing available is ListChanged, and it is pretty
useless for what I am doing. I suppose I could inherit from
BindingSource and overload the methods and add an event.
Is this the way to go? or is there something built in?
~Travis- Hide quoted text -

- Show quoted text -

My thoughts exactly. Now I just have to figure out how to make
everyone aware of it.

Thanks,
Travis
 

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

Top