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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Thread ID:





37133 Nov 16,2005 11:29 AM UTC Nov 17,2005 09:46 AM UTC WinForms 5
Tags: GridControl
Asked On November 16, 2005 11:29 AM UTC

Hi There, I am using GridDataBound Grid.I have one method called "InsertRows" which will insert required number of rows in the grid.Currently I am disabling commandstack while doing this operation,but now I need to enable it to record this Insert also.Now my question if I want to Undo the Insert,how to identify that the recent action is Insert in the Undo(means what is recorder in the command stack for insert?). Thanks in advance, Thanks & Regards, Manohar B.

Administrator [Syncfusion]
Replied On November 16, 2005 11:46 AM UTC

It is not clear that you will be able to get this to work without you designing and implementing custom commands. The built-in undo/redo support is really intended for a GridControl that holds its own data. In a GridDataBoundGrid that is bound to a DataSource, there may be additional work that you need to do to insert and delete items from your datasource. To see what is on the top of a command stack, you can use the Peek method on the stack, eg. CommandStack.UndoStack.Peek.

Replied On November 16, 2005 02:37 PM UTC

Hi Clay, I have one doubt.When we edit some text/write new text in any cell of GDBG.And then executed "GDBG.CommandStack.Undo",if I go to quickwatch and if i see,"GridChangeCellsCommand" is recorded.Now my question when and where exactly you are pushing this in to commandstack when we edit/add new text to the cell.Just I have taken one scenario to explain clearly. Thanks in advance, Thanks & Regards, Manohar B.

Administrator [Syncfusion]
Replied On November 16, 2005 03:17 PM UTC

That command is put on the stack in GridModel.ChangeCells. This method is inside the grid as part of the normal cell editing/navigation process. C:\Syncfusion30\Essential Suite\Windows\Grid.Windows\Src\Base\Model\GridModel.cs(7269): CommandStack.Push(new GridChangeCellsCommand(this, range, savedCellsInfo, StyleModifyType.Copy));

Replied On November 17, 2005 05:31 AM UTC

Hi Clay, For change of cells,"CommandStack.Push(new GridChangeCellsCommand(this, range, savedCellsInfo, StyleModifyType.Copy));".Like vice Is there any built in class availble for insert,so that I can use the same.I will defnately write my required functionality,I just want till what extent the existing code will support me in achieving this task. Thanks & Regards, Manohar B.

Administrator [Syncfusion]
Replied On November 17, 2005 09:46 AM UTC

If you do a search in the grid source coude fro commandstack.push, below are the hits you get. So, these are the command objects that are available in the grid. BUT, their implementation does not have special knowledge of a GridDataBoundGrid or of its datasource. So, for example, the GridModelRemoveRangeCommand with its InsertAt and InsertTo row parameters will not insert into your datasource. Instead, you would have to derive the class and override its Execute function to handle the appropriate actions based on passed arguments. You may have to add additional fields to your derived class to manage the data required to be able to undo/redo the action handled by the command. You would also have to handle a grid event to be able to push your derived command onto the commandstack at the appropriate time. Grid.Windows\Src\Base\Model\GridModel.cs(7269): CommandStack.Push(new GridChangeCellsCommand(this, range, savedCellsInfo, StyleModifyType.Copy)); Grid.Windows\Src\Base\Model\GridModelBanneredRanges.cs(268): model.CommandStack.Push(new GridModelSetBanneredRangesCommand(this, oldRanges, !setOrReset)); Grid.Windows\Src\Base\Model\GridModelCoveredRanges.cs(277): model.CommandStack.Push(new GridModelSetCoveredRangesCommand(this, oldRanges, !setOrReset)); Grid.Windows\Src\Base\Model\GridModelHideRowColsIndexer.cs(599): model.CommandStack.Push(new GridModelSetRowColHideCommand(this, from, last, savedValues)); Grid.Windows\Src\Base\Model\GridModelRowColOperations.cs(311): model.CommandStack.Push(new GridModelSetDefaultSizeCommand(this, savedValue)); Grid.Windows\Src\Base\Model\GridModelRowColOperations.cs(378): model.CommandStack.Push(new GridModelSetHeaderCountCommand(this, savedValue)); Grid.Windows\Src\Base\Model\GridModelRowColOperations.cs(562): model.CommandStack.Push(new GridModelSetFrozenCountCommand(this, savedValue)); Grid.Windows\Src\Base\Model\GridModelRowColOperations.cs(642): model.CommandStack.Push(new GridModelInsertRangeCommand(this, from, count, iro)); Grid.Windows\Src\Base\Model\GridModelRowColOperations.cs(729): model.CommandStack.Push(new GridModelRemoveRangeCommand(this, insertAt, insertAt+count-1)); Grid.Windows\Src\Base\Model\GridModelRowColOperations.cs(803): model.CommandStack.Push(new GridModelMoveRangeCommand(this, target, count, from)); Grid.Windows\Src\Base\Model\GridModelRowColSizeIndexer.cs(746): model.CommandStack.Push(new GridModelSetRowColSizeCommand(this, from, last, savedValues));


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon