Editor for WinForms | ComponentOne
C1.Win.C1Editor.4.5.2 Assembly / C1.Win.C1Editor Namespace / C1Editor Class / CanRedo Method
Example

In This Topic
    CanRedo Method
    In This Topic
    Returns a value that indicates whether the most recent undo action can be redone.
    Syntax
    'Declaration
     
    Public Function CanRedo() As System.Boolean
    public System.bool CanRedo()

    Return Value

    True if the most recent undo action can be redone; otherwise, False.
    Example
    This example shows how to create a custom context menu that can be linked to a C1Editor control and has Undo and Redo buttons.
    class MyContextMenuStrip : ContextMenuStrip
    {
        private C1Editor _owner;
        private ToolStripMenuItem _btnUndo, _btnRedo;
                
        public MyContextMenuStrip(C1Editor editor)
        {
            // save reference to parent control
            _owner = editor;
                
            // create menu items
            _btnUndo = (ToolStripMenuItem)Items.Add("Undo");
            _btnUndo.ShortcutKeys = Keys.Control | Keys.Z;
            _btnRedo = (ToolStripMenuItem)Items.Add("Redo");
            _btnRedo.ShortcutKeys = Keys.Control | Keys.Y;
        }
                
        protected override void OnItemClicked(ToolStripItemClickedEventArgs e)
        {
            Close();
                
            if (e.ClickedItem == _btnUndo)
                _owner.Undo();
            else if (e.ClickedItem == _btnRedo)
                _owner.Redo();
            base.OnItemClicked(e);
        }
                
        protected override void OnOpening(System.ComponentModel.CancelEventArgs e)
        {
            _btnUndo.Enabled = _owner.CanUndo;
            _btnRedo.Enabled = _owner.CanCut;
            base.OnOpening(e);
        }
    See Also