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 from a GridDataControl which is data bound


The default delete functionality of the grid when the delete key is pressed only seems to work once on the first key press so I disabled this and tried to write my own on key press (for the delete key)


e.g:
int itemIndex = grid.Model.CurrencyManager.CurrentRecordIndex;

(grid.ItemsSource as ObservableCollection).RemoveAt(itemIndex);

// This works but
// CurrentRecordIndex will now be -1

// this line of code almost makes it work by setting the new current row to what it was before delete. The only problem here is that the row selector dissappears from the UI
grid.Model.CurrencyManager.MoveTo(itemIndex);

Also when the grid is grouped the concurrency manager will return the wrong index.

Is there an easier way to delete records from a bound grid?

1 Reply

MS Mohamed Suhaib Fahad A. Syncfusion Team July 1, 2009 12:18 PM UTC

Hi Hayden,

Thanks for using Syncfusion products.

Deleting a row directly from the Grid is quite tricky and the internal logics that does this functionality is marked internal. The best way to do is to access the underlying source and directly remove it from the list. I have a sample created for you that does it,

http://www.syncfusion.com/uploads/redirect.aspx?file=GridSample_324ae33b.zip&team=development

Please check it out and let me know if you want any more details.

Thanks,
Fahad
Grid.WPF Team
Syncfusion Inc.,

Loader.
Live Chat Icon For mobile
Up arrow icon