-
Mar 20th, 2018, 12:54 PM
#1
Thread Starter
Banned
Copy Paste Shortcut key
How do i add a copy , paste , cut, delete shortcut key to my appliaction
-
Mar 20th, 2018, 02:36 PM
#2
Re: Copy Paste Shortcut key
It depends. If you are using a ToolStripMenuItems for the commands, then you'd assign the ShortcutKeys property equal to the various combinations either in the designer or via code:
Code:
CopyToolStripMenuItem.ShortcutKeys = Keys.Control Or Keys.C
Otherwise, if you just want a global command to reside on the Form, then generate the KeyDown event and check for the various combinations:
Code:
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.Control AndAlso e.KeyCode = Keys.C Then
ElseIf e.Control AndAlso e.KeyCode = Keys.X Then
'ElseIf etc.. Then...
End If
End Sub
Just be mindful that in this case you'd probably want to set the Form's KeyPreview property to True.
-
Mar 20th, 2018, 03:08 PM
#3
Re: Copy Paste Shortcut key
Actually, you may not need this. Windows already has such functionality that will work with textboxes, and I seem to remember that's what you were using. Ctrl+C is copy, Ctrl+V is paste, Ctrl+X is cut. Are you needing more than that?
My usual boring signature: Nothing
-
Mar 21st, 2018, 05:25 AM
#4
Re: Copy Paste Shortcut key
Originally Posted by Shaggy Hiker
Actually, you may not need this. Windows already has such functionality that will work with textboxes, and I seem to remember that's what you were using. Ctrl+C is copy, Ctrl+V is paste, Ctrl+X is cut. Are you needing more than that?
I recently inherited an application to support and the previous programmer set up an "Edit" menu for cut, copy, paste. I'd post a picture but one of the first things I did was remove it and let standard Windows key combinations work. I got a lot of thanks for that...I had asked the users first before gutting it and not one person preferred the menu over keys. I say; let Windows work the way Windows works. That way all your apps are relatively consistent.
It used ToolStripMenuItems as mentioned in post #2.
Please remember next time...elections matter!
-
Mar 21st, 2018, 07:37 AM
#5
Re: Copy Paste Shortcut key
Originally Posted by TysonLPrice
I recently inherited an application to support and the previous programmer set up an "Edit" menu for cut, copy, paste. I'd post a picture but one of the first things I did was remove it and let standard Windows key combinations work. I got a lot of thanks for that...I had asked the users first before gutting it and not one person preferred the menu over keys. I say; let Windows work the way Windows works. That way all your apps are relatively consistent.
It used ToolStripMenuItems as mentioned in post #2.
Not just that but, unless you have set the ContextMenuStrip property of a TextBox explicitly, right-clicking a TextBox will display the default context menu and that contains Cut, Copy and Paste items. The same goes for a ComboBox with its DropDownStyle set to DropDown, although not for a RichTextBox.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|