CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2008
    Posts
    66

    How to enable shortcut ctrl+c ctrl+v

    How do I enable the shortcut keys ctrl+c ctrl+v in order to copy and paste some text in my textbox fields?

    I have to right click and select paste option in order to paste some text at them.

    If I only press ctrl+v nothing occurs.

    Thank you in advance.

  2. #2
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: How to enable shortcut ctrl+c ctrl+v

    they are handled by default on text boxes and rich text boxes and you don't have to do anything in order to make it happen.

    post some code that can reproduce your issue with it not working.

  3. #3
    Join Date
    May 2008
    Posts
    66

    Re: How to enable shortcut ctrl+c ctrl+v

    Hi!

    The shortcuts in textboxes are not working in my application. I set the ShortcutsEnable property to true.

    It is only possible to copy something to them right clicking the mouse and so, selecting the paste option.

    Does someone know how to enable the copy paste shortcuts?

    Thank you!

  4. #4
    Join Date
    Jan 2007
    Posts
    491

    Re: How to enable shortcut ctrl+c ctrl+v

    Create a menu (Set its visible to false if you don't want the user to see it) and create a new MenuItem called "Copy". Set its shorcut value to "Ctrl+C". Then, create the click event for this menu item, and write the following code inside:
    Code:
    Clipboard.SetText(textBox1.Text); //put the text of textBox1 in the clipboard
    The "Pasting" shortcut is very similar. All you have to do is to create another MenuItem, set its shorcut to "Ctrl+V" and write in the click event:
    Code:
    textBox1.Text = Clipboard.GetText();
    Or:
    Code:
    SendKeys.Send(Clipboard.GetText()); //Sending the text in the clipboard to where the cursor is
    I'm asumming you are handling with windows application. If not, please tell what kind of project you do work with.

  5. #5
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: How to enable shortcut ctrl+c ctrl+v

    Did you read the documentation?

    http://msdn.microsoft.com/en-us/libr...tsenabled.aspx
    Note:
    The TextBox control does not support shortcut keys.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  6. #6
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: How to enable shortcut ctrl+c ctrl+v

    very strange.

    I just created a new form, dropped 2 text boxes on it, hit F5, typed in one text box, pressed CTRL + A, CTRL + C, clicked on the second text box, pressed CTRL + V and it pasted in the text...

    so how can it work on one machine, and not on another???

  7. #7
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

  8. #8
    Join Date
    Jun 2008
    Posts
    2,477

    Re: How to enable shortcut ctrl+c ctrl+v

    Yet, right above the bit which says that the TextBox does not support shortcut keys, there is this little snippet:

    Code:
     Use the ShortcutsEnabled property to enable or disable the following shortcut key combinations:
    
        *
    
          CTRL+Z
        *
    
          CTRL+E
        *
    
          CTRL+C
        *
    
          CTRL+Y
        *
    
          CTRL+X
        *
    
          CTRL+BACKSPACE
        *
    
          CTRL+V
        *
    
          CTRL+DELETE
        *
    
          CTRL+A
        *
    
          SHIFT+DELETE
        *
    
          CTRL+L
        *
    
          SHIFT+INSERT
        *
    
          CTRL+R 
    
    You can override this property to specify other shortcut keys.
    They do support standard shortcuts, I don't know what is up with that page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured