Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

MenuStrip blocks TextBoxes

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:

  • http://www.pcreview.co.uk/forums/textbox-copy-and-paste-problem-t2893739.html
  • https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=696702&SiteID=1
like image 703
user799821 Avatar asked Feb 08 '12 14:02

user799821


People also ask

Why is my CTRL C and V not working in Word?

Go to File>Options>Customize Ribbon and click on the Keyboard shortcuts: Customize button. Then press Ctrl+V when the selection is in the Press new shortcut key: control and see what appears to the right of "Currently assigned to:" It should be EditPaste .

Why can't I Ctrl C Ctrl V?

When Ctrl V or Ctrl V not working, the first and easiest method is to perform a restart of your computer. It has been proven by lots of users to be helpful. To restart your computer, you can click on the Windows menu on the screen and then click on the Power icon and select Restart from the context menu.


1 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);
    }
like image 176
Ivan Ičin Avatar answered Oct 19 '22 06:10

Ivan Ičin