title: How to make work standard hotkeys (Ctrl+C, Ctrl+Z) in DataGridView Edit Mode?
body: <p>I have simple .net application containing tabs and datargridviews on each tab. I've added main menu to the form and assigned hotkeys to menu items by using standard property:</p>
  
  <pre><code>editMenuItem = new ToolStripMenuItem("Copy", null, new System.EventHandler(onCopyCut_Click));
  editMenuItem.ShortcutKeys = Keys.Control | Keys.C;
  </code></pre>
  
  <p>The menu item shown above just copies cell content to clipboard. This works fine but in <strong>DGV's editing mode</strong> Ctrl+C and other standard hotkeys don't work anymore!</p>
  
  <p>I've set the <code>Form.KeyPreview</code> property to true, also tried to turn off the <strong>Handled</strong> property of my Form object but nothing happens:</p>
  
  <pre><code>    void FileOrginizerForm_KeyDown(object sender, KeyEventArgs e)
      {
              ...
          if (gridView.CurrentCell.IsInEditMode)
              e.Handled = false;
      }
  </code></pre>
  
  <p>What I'm missing? I'm sure this should be something simple.</p>
  
  <p>I found some information on <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripmenuitem.shortcutkeys.aspx" rel="nofollow">msdn help page's comments</a> :</p>
  
  <blockquote>
    <blockquote>
      <p>One thing that you need to keep in mind when setting these properties is that if
      you have a textbox control in your form, the menu item's ShortcutKeys will
      intercept that key combination and the textbox will never receive it e.g. if you
      have a paste (ctrl + v) ShortcutKey, <strong>your textbox will never receive the paste
      command</strong>. According to Microsoft, this is by design. Their workaround is to
      temporarily clear the menu item's ShortCutKey property to permit the paste
      command (most likely during an event) and then reset it after the event is
      finished.</p>
    </blockquote>
  </blockquote>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>Instead of turning on and off the menu shortcuts I ended up by calling menu event handlers from the main Form's KeyDown event handler:</p>
  
  <pre><code>    void FileOrginizerForm_KeyDown(object sender, KeyEventArgs e)
      {
          if (!gridView.CurrentCell.IsInEditMode)
          {
              if (e.KeyData == (Keys.Control | Keys.Z))
              {
                  this.editToolStripMenuItem.DropDownItems["Undo"].PerformClick();
              }
              else if (e.KeyData == (Keys.Control | Keys.Y))
              {
                  this.editToolStripMenuItem.DropDownItems["Redo"].PerformClick();
              }
              else if (e.KeyData == (Keys.Control | Keys.X))
              {
                      this.editToolStripMenuItem.DropDownItems["Cut"].PerformClick();
              }
              else if (e.KeyData == (Keys.Control | Keys.C))
              {
                      this.editToolStripMenuItem.DropDownItems["Copy"].PerformClick();
              }
              else if (e.KeyData == (Keys.Control | Keys.V))
              {
                      this.editToolStripMenuItem.DropDownItems["Paste"].PerformClick();
              }
              else if (e.KeyData == (Keys.Control | Keys.A))
              {
  
  this.selectToolStripMenuItem.DropDownItems["Select All"].PerformClick();
              }
          }
      }
  </code></pre>