delete entire row, undo


While trying to delete cells, rows in the syncfusion grid control for windows forms,
here is a part of my code
if (list.Count > 0)
{
int selectedRowTop = list.ActiveRange.Top;
int selectedRowBottom = list.ActiveRange.Bottom;
int selectedColumnLeft = list.ActiveRange.Left;
int selectedColumnRight = list.ActiveRange.Right;

thegrid.removerange(.....)
This works well for the user selcts a range of cell.
Suppose the user selects an entire row, then selectedColumnLeft , selectedColumnRight are coming to be 0
How should I delete an entire row?

2) Please send me some sample code for undo functionality




1 Reply

JP Jeya Preetha M Syncfusion Team April 24, 2012 10:30 AM UTC

Hi Smitha,

Thank You for your interest in Syncfusion Products.

To delete an entire row in the Grid Control, please set "selectedColumnLeft=0" and "selectedColumnRight=e.colcount".


GridRangeInfo range = GridRangeInfo.Cells(top, 0, bottom, e.colcount);


To enable Undo/Redo for the current cell in the Grid Control , please try the following code snippet.

this.gridControl1.CommandStack.Enabled = true;

private void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Z && e.Control))
{
if (this.gridControl1.CurrentCell.IsEditing)
{
this.gridControl1.CurrentCell.EndEdit();
this.gridControl1.CommandStack.Undo();
}
}
}



Please let me know if you have any concerns.

Regards,
Jeya Preetha M



Loader.
Up arrow icon