We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Deleting rows bound to an Observable Collection

I have a GridDataControl in WPF that allows the selected row to be deleted by pressing the "delete" key.  I need to capture some information from the record being deleted, but I cannot find the event that fires when the record is being deleted

3 Replies

DA Divya A Syncfusion Team April 11, 2013 12:45 PM UTC

Hi Todd,

 

Thank you for using Syncfusion products.

 

You can achieve your requirement by handling CollectionChanged event. This event fires whenever a change is done to the underlying Collection like adding, deleting, moving records. From the argument e.Action you can find whether the event is invoked while adding, deleting, or moving records. The deleted records can also be retrieved from the argument e.OldItems.

 

 

Code Snippet:

 

this.SyncGrid.ModelLoaded += new EventHandler(SyncGrid_ModelLoaded);

 

void SyncGrid_ModelLoaded(object sender, EventArgs e)

 {

    this.SyncGrid.Model.View.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(View_CollectionChanged);

 }

 

void View_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

 {

    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)

    {

       var Arraylist = ((System.Collections.ArrayList.ReadOnly(e.OldItems)));

       var Item = ((Products)Arraylist[0]);

    }

 }

 

 

Please let us know if you need further assistance.

 

Regards,

Divya.



TL Todd Lichtas April 11, 2013 05:18 PM UTC

Excellent, exactly what I was looking for.  Thank you.
 
Todd


DA Divya A Syncfusion Team April 12, 2013 11:45 AM UTC

Hi Todd,

 

Thanks for your update.

 

Please let us know if you need further assistance and we will be happy to assist you.

 

Regards,

Divya.


Loader.
Live Chat Icon For mobile
Up arrow icon