Click to See Complete Forum and Search --> : How to enable shortcut ctrl+c ctrl+v


gborges
October 28th, 2008, 10:36 AM
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.

MadHatter
October 28th, 2008, 10:43 AM
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.

gborges
October 28th, 2008, 11:43 AM
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!

Talikag
October 28th, 2008, 02:41 PM
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:

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:

textBox1.Text = Clipboard.GetText();

Or:

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.

TheCPUWizard
October 28th, 2008, 02:44 PM
Did you read the documentation?

http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.shortcutsenabled.aspx

Note:
The TextBox control does not support shortcut keys.

MadHatter
October 28th, 2008, 07:59 PM
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???

MadHatter
October 28th, 2008, 10:07 PM
http://video.google.com/videoplay?docid=3323637278959008491

BigEd781
October 28th, 2008, 11:41 PM
Yet, right above the bit which says that the TextBox does not support shortcut keys, there is this little snippet:

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.