locked
Copy past in MDIParent c# RRS feed

  • General discussion

  • Hi,
    I am having the following problem.
    "I have a program with an MDIParent and child forms....I can not seem to copy and paste using keyboard shortcuts (ctrl+C, ctrl+V) to the MDIchild forms...I can copy and paste using mouse right click but just not with the keyboard."

    TO test this  I have created a two test app.
    1. one app has From1 with two textbox - it has copy past in both shortcut and rightclick.
    2. another application has an MDIParent and one from1, and I have changed MDIParent as start up page and From1 as teh child page of MDIParent and the childform has the two textbox. When I press new in running mdiparent the child form(From1) will open. Here i have checked copy paste. chortcut key is not working and rightclick optionis working.
    I want to do copy paste with shortcut key in MDIParent cild form's textbox. Can any one help me?

    Wednesday, July 20, 2011 6:57 AM

All replies

  • use keypress event or processcmdkey method to handle keyboard shortcuts. use clipboard to hold copied data & retrieve copied data from clipboard for paste operation.

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
            {
                KeyEventArgs e = new KeyEventArgs(keyData);
                if ((e.Modifiers & Keys.Control) == Keys.Control & e.KeyCode == Keys.C)
                {
                    // Copy data from Source Control
                    Clipboard.SetText(this.textBox1.Text);
                }
                else if ((e.Modifiers & Keys.Control) == Keys.Control & e.KeyCode == Keys.V)
                {
                    if (Clipboard.ContainsText())
                    {
                        // Paste data to the desired control
                        this.textBox2.Text = Clipboard.GetText();
                    }
                }
                return this.ProcessCmdKey(ref msg, keyData);
            }
    Use Context menu to handle right click opearations..

    It all Happenz Sendil

    Monday, January 7, 2013 12:43 PM
  • Hey i have faced same problem in my mdi windows app, Here  I posted the solution.

    http://www.learnsharecorner.com/solved-copy-paste-shortcut-in-mdi-form-windows-app-asp-net-c/

    Hope it solve your problem too.


    mukesh

    Sunday, January 4, 2015 9:55 AM