The chart fires the ChartStartChanging event when the user starts an UI operation, for instance, moving a bar. The ChartEndChanging event notifies your application once the user operation on the chart ends. By default, each undo/redo operation is added sequentially as they occur. You can call the StartBlockUndoRedo method during the ChartStartChanging event so all operations that are about to begin will be as a block when calling the EndBlockUndoRedo during the ChartEndChanging event. For instance, if a bar is related to multiple bars using grouping options, so if a bar is moved other bars must be moved, the undo/redo operations are added sequentially as they appear. So calling the Undo action will restore moving a bar once at the time. Using the StartBlockUndoRedo/EndBlockUndoRedo methods you can control the block of undo/redo operations being grouped in a block, so next time the Undo/Redo operation is performed, the entire block of operations is performed or restored at once. For instance, the SchedulePDM method performs multiple operations during bars, so all of them are grouped as a block.
For instance, we we have the following chart:
In this case the, the K1, K2 and K3 bars are grouped, so moving any bar will result in moving relative bars.
The following screen shot shows the chart after moving the bar K3 to a new position as well as a to a new parent,
so the undo/redo queue looks like:
In this case, we need to press twice the CTRL + Z to restore back the chart as it was before moving the bar K3.
Instead if we are using the StartBlockUndoRedo and EndBlockUndoRedo methods as follow:
Private Sub G2antt1_ChartStartChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum) G2antt1.Chart.StartBlockUndoRedo End Sub Private Sub G2antt1_ChartEndChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum) G2antt1.Chart.EndBlockUndoRedo End Sub
We have the undo/redo queue as follows ( if we perform the same operation ):
In this case, we need to press only once the CTRL + Z to restore back the chart as it was before moving the bar K3.