Current filter:
                                You should refresh the page.
                                  • Hi

                                    Is there any inbuilt command stack for winform Spreadsheet control. Where the changes in the sheet are persisted.

                                    Please let us know if we can access that.

                                    Thanks & Regards
                                    Nanda

                                1 Solution

                                Creation Date Importance Sort by

                                Thank you for your clarification. Our SpreadsheetControl also tracks the workbook activity. You can access a SpreadsheetHistory object using the SpreadsheetControl.Document.History property.

                                You can undo (the SpreadsheetHistory.Undo method) and redo (the SpreadsheetHistory.Redo method) the last actions.

                                However, our SpreadsheetControl does not allow accessing/adding/removing a specific action from the SpreadsheetControl's document history.

                                Unless I'm mistaken, the https://help.syncfusion.com/cr/cref_files/windowsforms/Syncfusion.Grid.Windows~Syncfusion.Windows.Forms.Grid.GridModelCommandManager.html article you pointed out is related to Syncfusion Grid. Our WinForms Suite also has a Data Grid. Did you consider using our Data Grid in your application to emulate functionality of the Syncfusion Grid?

                                Updated

                                From what I gather, a user inserts/removes cell ranges using custom menu items in your project. So, unless I'm mistaken, these operations are performed using the SpreadsheetControl's API.
                                If so, wrap the code to insert/remove a cell range into the SpreadsheetControl.Document.BeginUpdate- SpreadsheetControl.Document.EndUpdate methods statement. In this case, this operation will be executed in a single history transaction. So, a user will be able to revert it back with one Undo operation.
                                For instance, the following code that populates 5 cells with values and changes their formatting can be rejected with one Undo operation:

                                [C#]
                                int rowCount = 5; int rowIndex = 1; sscConverter.Document.BeginUpdate(); for (int i = rowIndex; i <= rowCount; i++) { sscConverter.ActiveWorksheet.Cells["A" + i].Value = 1; sscConverter.ActiveWorksheet.Cells["A" + i].Font.Name = "Times New Roman"; sscConverter.ActiveWorksheet.Cells["A" + i].FillColor = Color.LightBlue; } sscConverter.Document.EndUpdate();
                                Show all comments
                                • NANDA KUMAR 6 08.02.2019

                                  Hi,

                                  Thanks for the response.

                                  Unfortunately moving to Datagrid is not a feasible option for us at this stage of the project.

                                  We would request help to achieve the functionality of reverting back or rolling back of a set of changes at once.
                                  (User can insert a custom object that will normally get displayed as a range on the sheet and an undo option should revert back this change at once)

                                  Thanks & Regards
                                  Nanda 

                                • Yulia (DevExpress Support) 08.05.2019

                                  Hi,

                                  Thank you for your clarification. Our SpreadsheetControl does not allow executing the Undo operation for a specific operation in the document history. It is only possible to undo the last operation performed in a workbook.

                                  Would you please clarify how this custom object can be inserted into SpreadsheetControl? Is it pasted using the SpreadsheetControl API or UI facilities? We will check if we have any custom solutions for your scenario.

                                • NANDA KUMAR 6 08.05.2019

                                  Hi,

                                  Thanks for the response.

                                  Our scenario is in our context menu while selecting on one menu item or selecting a menu item a dialog box that allows the user to make some selection and based on the user's selection, a range of rows/columns will be inserted which will apply different styles like font patterns etc.
                                  So we would like to check if the last operation was inserting or deleting a range of cells then would it be possible to revert the same.

                                  Thanks & Regards
                                  Nanda

                                • Yulia (DevExpress Support) 08.05.2019

                                  From what I gather, a user inserts/removes cell ranges using custom menu items in your project. So, unless I'm mistaken, these operations are performed using the SpreadsheetControl's API.

                                  If so, wrap the code to insert/remove a cell range into the SpreadsheetControl.Document.BeginUpdate- SpreadsheetControl.Document.EndUpdate methods statement. In this case, this operation will be executed in a single history transaction. So, a user will be able to revert it back with one Undo operation.

                                  For instance, the following code that populates 5 cells with values and changes their formatting can be rejected with one Undo operation:

                                  [C#]
                                  sscConverter.Document.BeginUpdate(); int rowCount = 5; int rowIndex = 1; for (int i = rowIndex; i <= rowCount; i++) { sscConverter.ActiveWorksheet.Cells["A" + i].Value = 1; sscConverter.ActiveWorksheet.Cells["A" + i].Font.Name = "Times New Roman"; sscConverter.ActiveWorksheet.Cells["A" + i].FillColor = Color.LightBlue; } sscConverter.Document.EndUpdate();

                                  I hope this approach will be useful for your task. If I understood your scenario incorrectly, and the task cannot be resolved with this approach, please send me a small sample that shows the problem. I will be happy to assist you.

                                • NANDA KUMAR 6 08.13.2019

                                  Hi,

                                  There's a requirement to do selective undo/redo and for that, we have implemented something similar to the attached sample application.In the application, the Undo button allows selective undo operation of the filling of the range but when the Format dialog is opened and a style is applied (say, a cell filled with a pattern) and then if the Undo button is clicked, the Undo operation is not working
                                  It'd be helpful if you could help us with details on the Clear() method as Clearing the current history gets to a situation where the Undo operation has no effect even if the Document's History has items in it
                                  Any inputs in this regard are highly appreciated.

                                  Attached a short video that describes the issue and the sample project.

                                  Thanks,
                                  Nanda

                                • Yulia (DevExpress Support) 08.14.2019

                                  Hi,

                                  Note that besides the collection of history items, DocumentHistory has the current state - the index of the current history item. This state determines if it is possible to undo/redo actions. Since you don't set the document history's current state in your sample, the Undo operation is not executed.

                                  The DocumentHistory object is synchronized with SpreadsheetControl's document model state. It is not correct to undo/redo a specific history item without changing the document model state accordingly. Moreover, some operations in SpreadsheetControl are composite, they consist of several actions. It is not correct to undo/redo a separate action in this case or undo/redo actions in a different order.

                                  Such modifications may transform the document model into an unpredictable state. We don't recommend operating with the document history this way.

                                  I found that you wrap the code to apply a style configured in the "Format Cells" dialog for the selected cell range into your custom history items processing routine.

                                  [C#]
                                  tracker.SetUndo(); Formatting style = rangeB9D6.BeginUpdateFormatting(); FormatCellsNumberCommand command = new FormatCellsNumberCommand(spreadsheetControl1); command.Execute(); rangeB9D6.EndUpdateFormatting(style); tracker.SetRedo();

                                  Note that all the changes made in the "Format Cells" dialog are wrapped in a single transaction. This transaction is applied when the dialog is closed. In other words, all the changes a user made can be reset using a single Undo action.

                                  So, it is not quite clear to me why you wish to process this operation in a custom manner. Please describe your scenario in greater detail or demonstrate the task you need to accomplish with a sample project. We will do our best to find an appropriate solution for it.

                                • NANDA KUMAR 6 08.19.2019

                                  Hi,

                                  Thanks for the update. Our requirement can be summarized as follows:

                                  1. A user can create/delete some custom objects using a custom dialog box (similar to the Format dialog) that can insert/delete certain rows and columns on the spreadsheet
                                  2. The View class that holds the SpreadSheet control has similar objects in it as children.
                                  3. The implementation has been that when such an object is created, it holds the information of the total cells required by it and once such an object is created (There will be a lot of already saved custom objects), the spreadsheet is painted (between a begin/end update) and this is a generic method that draws all the child objects on the spreadsheet
                                  4. The problem that we are facing is when an Undo is called after the user creates a custom object, the spreadsheet turns blank as the last action is the Refresh method to paint the spreadsheet control but to the user, the last action is the creation of the custom object. In order to achieve the rollback/Undo of this user action (of creating/deleting of custom objects or in other words to only allow undoing the user action) that the request of selective Undo action was made.

                                  Hope this is helpful. Any inputs in this regard are highly appreciated.

                                • Yulia (DevExpress Support) 08.20.2019

                                  Hi,

                                  Thank you for describing your scenario. While our SpreadsheetControl does not provide a public API to accomplish this task, you can implement a custom document history to undo/redo changes according to your scenario specifics.

                                  As you probably know, each UI action in SpreadsheetControl is associated with the corresponding command. You can check the moment when any UI command is executed using the CommandExecutionListenerService descendant. Then, count the number of executed transactions.

                                  I have created a sample that demonstrates how to replace the built-in CommandExecutionListenerService service with a custom one. You can find the project in the attachment.

                                  This approach should allow you to determine the number of calls of the Undo/Redo methods that are necessary to undo/redo your custom operations.

                                  Note that the CommandExecutionListenerService class is a part of SpreadsheetControl's internal API. This API is not documented and may be changed in future versions. Should you face any difficulties while upgrading your project, don't hesitate to contact our team. We will do our best to assist you.

                                • NANDA KUMAR 6 08.20.2019

                                  Thanks for the update and sample.

                                  With this approach we'd request more inputs on how to selectively perform Undo or redo operations on user actions.
                                  The user actions could be the 3rd and 4th items in the History Stack and the actions in the grid refresh could be the 5th item. And when the Undo is done, the 5th item should be skipped and the Undo action should be on the 4th item.
                                  It was found that with the Format dialog from the context menu, the command is not SpreadsheetCommandId.FormatCellStyle
                                  but FormatCellsContextMenuItem, hence we request more info on when SpreadsheetCommandId.FormatCellStyle command will get invoked.

                                  Thanks & Regards
                                  Nanda

                                • Yulia (DevExpress Support) 08.21.2019

                                  Note that it is not correct to undo/redo actions in a different order. It may break the document history and put the SpreadsheetControl's document model into an unpredictable state.
                                  To accomplish the task, log all the user actions and your custom operations (e.g., refresh). Count how many history transactions were performed after a certain user action. If it is necessary to cancel a user action, execute the SpreadsheetHistory.Undo method as many times as history transactions were registered after this action

                                  For instance, in your sample, it is necessary to register the 3rd and 4th user actions and the "grid refresh" operation (the 5th item) in your custom history helper. Then, if a user needs to undo the 4th action, you need to execute the SpreadsheetHistory.Undo method twice: first, to undo your custom grid refresh operation and, second, to undo the user action.

                                  >>we request more info on when SpreadsheetCommandId.FormatCellStyle command will get invoked<<
                                  The SpreadsheetCommandId.FormatCellStyle command is executed when a cell style is selected from the Styles Ribbon Gallery (see the attached video).

                                • NANDA KUMAR 6 08.22.2019

                                  Thanks for the response.

                                  It is the custom refresh (the 5th item in the example) that we would like to be transparent to the user and it is that item which needs to be skipped, and Undo call to be made on the 4th item. Could you please let us know is there any way to achieve this.

                                  Thanks & Regards
                                  Nanda

                                • Yulia (DevExpress Support) 08.22.2019

                                  It is not clear from your description what this custom refresh does. Are you calling the SpreadsheetControl.Refresh method? What do you mean by "to be transparent to the user"? Send us a small sample with the custom refresh implementation and a video that shows the current issue.

                                • NANDA KUMAR 6 08.28.2019

                                  Hi,
                                  We've created a sample application that describes our issue and attached a short video that shows the working of the application.
                                  When the Undo method is invoked after inserting a custom object, we would like it to delete all the inserted records and not remove everything as it's happening now. We would like the DrawData method to be transparent to the user.
                                  Thanks & Regards
                                  Nanda

                                • Yulia (DevExpress Support) 08.28.2019

                                  Hi,

                                  Thank you for providing the test project. I checked the "Insert Custom Object" menu item click handler and found that you clear all the cells of the active worksheet, save the newly added custom object to an XML file, and import cell values from this XML file.

                                  [C#]
                                  private void CreateCustomInputObjects() { Common.CreateXmlFile(); InputForm inputForm = new InputForm(); if (inputForm.ShowDialog(this) == DialogResult.OK) { MainPage.CreateCustomInput(MainPage.MainSheet.ActiveCell, inputForm.Count, inputForm.TypeOfObject); MainPage.SaveData(); MainPage.MainSheet.ActiveWorksheet.Clear(MainPage.MainSheet.ActiveWorksheet["$A:$XFD"]); MainPage.DrawData(); } }

                                  Since the cell values are imported in the SpreadsheetControl.BeginUpdate-EndUpdate statement, all these modifications are written as a single transaction into the document history.

                                  If you comment the code to clear and restore the previously added cells values, only the last added custom object will be canceled after executing the Undo operation.

                                  [C#]
                                  MainPage.CreateCustomInput(MainPage.MainSheet.ActiveCell, inputForm.Count, inputForm.TypeOfObject); //MainPage.SaveData(); //MainPage.MainSheet.ActiveWorksheet.Clear(MainPage.MainSheet.ActiveWorksheet["$A:$XFD"]); MainPage.DrawData();

                                  Could you please clarify why you need to clear and restore cell values each time a new object is added?

                                • NANDA KUMAR 6 09.06.2019

                                  Thanks for the update and sorry for the delayed response.
                                  The reason why we need to clear and restore cell values each time a new object is added is because the custom objects in the sheet are linked to one another and there could be value changes that need to be updated.

                                  Please let us know your thoughts.

                                • Yulia (DevExpress Support) 09.06.2019

                                  Thank you for your clarification. Unless I'm mistaken, all cell values should be also recalculated and restored after the object insertion is canceled (the Undo command is executed).

                                  If so, this functionality cannot be implemented at the SpreadsheetControl level, since the control is not related to a data source with business objects.

                                  You will need to implement the change tracking mechanism for the data source at the data layer in this case.
                                  Alternatively, use our GridControl instead of the spreadsheet. The GridControl is a data-aware control. It provides events for tracking data modifications in the associated data source.

                                • NANDA KUMAR 6 09.09.2019

                                  Thanks for the response, request your inputs on following points
                                  1 - Guidelines of transition from Spreadsheet to GridControl
                                  2 - Guidelines from moving from Syncfusion grid control to DevEx grid control
                                  3 - Undo/Redo stack
                                  Option to access, add, remove and clear the undo/redo stack of the Devex grid
                                  4. Any options to support formula cells in the DevEx grid control
                                  5. Is there Virtual grid option that will help us to handle large data in devex grid

                                • Yulia (DevExpress Support) 09.09.2019

                                  Since your questions are mostly related to our GridControl, I've created a separate ticket on your behalf (T813314: How to migrate from Syncfusion Grid control to DevExpress GridControl ). It has been placed in our processing queue and will be answered shortly.