# C1.Win.C1Editor.C1Editor.Undo

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_C1Editor_C1Editor_Undo_" data-uid="C1.Win.C1Editor.C1Editor.Undo*">Undo Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_C1Editor_C1Editor_Undo_" data-uid="C1.Win.C1Editor.C1Editor.Undo*"></a>
<h4 id="C1_Win_C1Editor_C1Editor_Undo" data-uid="C1.Win.C1Editor.C1Editor.Undo">Undo()</h4>
<div class="markdown level1 summary"><p>Performs Undo action in the current editor mode (design or source).</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Undo()</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Undo()</code></pre>
</div>
<h5 id="C1_Win_C1Editor_C1Editor_Undo_examples">Examples</h5>
<p>This example shows how to create a custom context menu that can be linked to a C1Editor control and has Undo and Redo buttons.
<pre><code class="lang-csharp">class MyContextMenuStrip : ContextMenuStrip
{
private C1Editor _owner;
private ToolStripMenuItem _btnUndo, _btnRedo;
<pre><code>            public MyContextMenuStrip(C1Editor editor)
            {
                // save reference to parent control
                _owner = editor;

                // create menu items
                _btnUndo = (ToolStripMenuItem)Items.Add(&quot;Undo&quot;);
                _btnUndo.ShortcutKeys = Keys.Control | Keys.Z;
                _btnRedo = (ToolStripMenuItem)Items.Add(&quot;Redo&quot;);
                _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);
            }&lt;/code&gt;&lt;/pre&gt;
</code></pre>
</code></pre>
</div>
