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 records in hierarchical grid

I need to delete records in a two level grid (both on parent and child level). I use GridSelectionFlags.Any. The following code works foreach(GridTable gt in this.gridGroupingControl1.Engine.EnumerateTables()) { if(gt.CurrentRecord != null) { int rowIndex = gridGroupingControl1.TableControl.CurrentCell.RowIndex; int colIndex = gridGroupingControl1.TableControl.CurrentCell.ColIndex; gt.CurrentRecord.Delete(); gridGroupingControl1.TableControl.CurrentCell.MoveTo(rowIndex, colIndex); return; } } However, if I delete in the child grid, there is not current cell after the deletion. What should I do to set a current cell after the deletion in the child grid?

2 Replies

AD Administrator Syncfusion Team April 19, 2005 04:05 AM

Try using this code: int i = gt.FilteredRecords.IndexOf(gt.CurrentRecord); gt.CurrentRecord.Delete(); gt.CurrentRecord = gt.FilteredRecords[i];


KK Kjetil Kåresen April 19, 2005 04:51 AM

I added the following tests to your code int i = gt.FilteredRecords.IndexOf(gt.CurrentRecord); if(i < 0) return; gt.CurrentRecord.Delete(); if(i >= gt.FilteredRecords.Count) return; gt.CurrentRecord = gt.FilteredRecords[i]; Now it works perfect. Thanks. Your help is invaluable and has convinced me to buy the Syncfusion package.

Loader.
Live Chat Icon For mobile
Up arrow icon