Detecting BindingSource "row deleted" event

T

Tomasz J

Hello Developers,

I have a DataGridView and BindingNavigator controls bound to a BindingSource
control.
User can delete a record using different methods: by pressing the DEL key,
pressing BindingNavigator Delete button. I may also want to add some other
methods calling BindingSource.RemoveCurrent().

How do I detect BindingSource "row deleted" event and get deleted row
reference, so I can post changes?

I would appreciate any hints.

Tomasz J
 
J

Jeffrey Tan[MSFT]

Hi Tomasz,

Getting the row deletion notification is easy. You may use
BindingSource.ListChanged event for this task. In this event, you may check
if the current list change type is ListChangedType.ItemDeleted. The code
snippet below demonstrates the logic:

private void bindingSource1_ListChanged(object sender, ListChangedEventArgs
e)
{
if (e.ListChangedType == ListChangedType.ItemDeleted)
{
}
}

However, to get the current deleted rows, there is no simple and easy way.
BindingSource.ListChanged is a completed event which fires after the row
deletion is done. When this event is firing, the row is already deleted
from the DataView. By default, the DataView will filter out these deleted
rows with DataView.RowStateFilter property.

The workarounds we have are:
1. If you are binding to the DataTable/DataSet, you may use
DataTable.RowDeleting event to get the deletion notification. And the
DataRowChangeEventArgs.Row will point to the current deleting row.
2. You have to catch all the deletion operations at various UI controls ,
such as DataGridView, BindingNavigator etc.. and find out the current
deleting rows

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

Tomasz J

Hello Jeffrey,

Catching all the deletion operations at various UI controls is precisely
what I am trying to avoid.

But I did not think about using DataTable.RowDeleting event - thank you.

BindingSource.ListChanged is useless for this purpose.
I think this BindingSource control functionality should really be improved.
Currently it is good only for MSDN demos.

Thanks,

Tomasz
 
J

Jeffrey Tan[MSFT]

Hi Tomasz,

Thank you for the feedback.

Yes, I agree the BIndingSource control model is not rich enough for your
special requirement. I would recommend you to submit a suggestion feedback
in the link below. The request will finally file in the Winform dev team
database for consideration:
https://connect.microsoft.com/VisualStudio?wa=wsignin1.0

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Tomasz,

Thank you for the feedback.

You may monitor this connect link and wait for the response from the dev
team. Note: the dev team does not have the same policy as MSDN newsgroup
support, so they may take a long time to response.

Anyway, if you need further help, please feel free to post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

Tomasz J

Well, the resolution, if ever provided, may take two full .Net Framework
releases.



Tomasz J
 
J

Jeffrey Tan[MSFT]

Hi Tomasz,

Yes, this type of design feature request has gone out of the newsgroup
support decision. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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