Show contents 

System > System Assembly Interfaces > IUndoRedo > IUndoRedo.Enabled

IUndoRedo.Enabled

Syntax

Enabled: Boolean;

Description

The Enabled property indicates whether the Undo/Redo stack is available for the user.

Comments

If the property value is False, the Undo stack is unavailable. To enable Undo/Redo stack, set the Enabled property to True. After that, all actions executed by the user are saved in the stack and, if required, can be canceled or repeated. The number of operations that can be stored in the stack is limited by the number set in the IUndoRedo.Limit property.

To undo the actions done, use the IUndoRedo.Undo method, to redo the actions done, use the IUndoRedo.Redo method.

When value of this property changes, value of the Enable property automatically changes in undo/redo stacks of all child objects.

Example

Executing the example requires a form that contains the ReportBox component named ReportBox1, the UiReport component named UiReport1, and the Toolbar component named Toolbar1. The Toolbar1 toolbar contains five buttons. Event handlers are added for each button. The UiReport component is a data source for ReportBox.

Class SAMPLEForm: Form
    ReportBox1: ReportBox;
    UiReport1: UiReport;
    Toolbar1: Toolbar;
    ToolbarButton1: ToolbarButton;
    ToolbarButton2: ToolbarButton;
    ToolbarButton3: ToolbarButton;
    ToolbarButton4: ToolbarButton;
    ToolbarButton5: ToolbarButton;
    UnRed: IUndoRedo;

    Sub SAMPLEFormOnCreate(Sender: Object; Args: IEventArgs);
    Var
        MB: IMetabase;
        Report: IPrxReport;
    Begin
        MB := MetabaseClass.Active;
        Report := MB.ItemById("Report_1").Edit As IPrxReport;
        UiReport1.Instance := Report;
        UnRed := Report.UndoRedo;
        UnRed.Enabled := True;
        UnRed.Limit := 10;
    End Sub SAMPLEFormOnCreate;

    Sub ToolbarButton1OnClick(Sender: Object; Args: IEventArgs);
    Begin
        If UnRed.UndoCount > 0 Then
            UnRed.Undo;
        End If;
    End Sub ToolbarButton1OnClick;
    
    Sub ToolbarButton2OnClick(Sender: Object; Args: IEventArgs);
    Begin
        If UnRed.RedoCount > 0 Then
            UnRed.Redo;
        End If;
    End Sub ToolbarButton2OnClick;
    
    Sub ToolbarButton3OnClick(Sender: Object; Args: IEventArgs);
    Begin
        UnRed.Flush;
    End Sub ToolbarButton3OnClick;
    
    Sub ToolbarButton4OnClick(Sender: Object; Args: IEventArgs);
    Begin
        If UnRed.UndoCount > 0 Then
            text := UnRed.UndoState(UnRed.UndoCount - 1).Action;
        End If;
    End Sub ToolbarButton4OnClick;
    
    Sub ToolbarButton5OnClick(Sender: Object; Args: IEventArgs);
    Begin
        If UnRed.RedoCount > 0 Then
            text := UnRed.RedoState(UnRed.RedoCount - 1).Action;
        End If;
    End Sub ToolbarButton5OnClick;

End Class SAMPLEForm;

After executing the example, clicking the button:

See also:

IUndoRedo