Shortcuts Ctrl+C Ctrl+V dont work in Textboxes if MenuStrip has this Shortcuts set

Goal: A Menustrip with Copy and Paste and the user shall see the Shortcut-Keys.

Problem: If you have a MenuStrip and set the ShortcutKeys the are "catched" by the Menu but no longer by the Textboxes. This means you cannot use Ctrl+C / V in the Textboxes - only by Right-Click. If you remove the Shortcuts the Textboxes work fine.

Why is that? Whats the solution if I dont want to name the Entry "Copy______Ctrl+C"?

Example Project: http://www.file-upload.net/download-4098087/MenuBlocksSTRG.zip.html

MSDN is down ATM i found this links:

Answers


This should work for copy, and you can take care of paste in same way:

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if (keyData == (Keys.Control | Keys.C) && textBox1.ContainsFocus)
        {
            Clipboard.SetText(textBox1.SelectedText);
            return true;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }

You probably have to handle things yourself in those cases.

Simple example:

private void copyToolStripMenuItem_Click(object sender, EventArgs e) {
  if (this.ActiveControl is TextBox) {
    Clipboard.SetText(((TextBox)this.ActiveControl).SelectedText);
  } else {
    // do your menu Edit-Copy code here
  }
}

private void pasteToolStripMenuItem_Click(object sender, EventArgs e) {
  if (this.ActiveControl is TextBox) {
    ((TextBox)this.ActiveControl).SelectedText = Clipboard.GetText();
  } else {
    // do you menu Edit-Paste code here
  }
}

If it still matters, the simple solution might be: Show only the shortcut keys text, as in the image.

In the TextBox set ShortcutsEnabled to true. That's all!


You need something like this?

ToolStripMenuItem Quit = new ToolStripMenuItem();
        Quit.Name = "quitToolStripMenuItem";
        Quit.Text = "&Quit";
        Quit.ShortcutKeys = Keys.Alt | Keys.F4;
        Quit.Click += new EventHandler(quitToolStripMenuItem_Click);

Need Your Help

Convert Hibernate @Formula (case ) to JOOQ field

sql hibernate dsl jooq

I am rewriting entire DB access layer from Hibernate to JOOQ and I face following issue.

How do you configure the location of TeamCity server cache and temp directories?

teamcity teamcity-9.0

This blog post indicates that it's possible to re-configure the locations of the $data/system/caches and $server/temp directories in order to optimise a TeamCity installation.