|
-
August 2nd, 2009, 04:51 PM
#1
Prevent Paste or Trap Paste into Edit Box
Found how to do it:
In the key down event for a text or rich text box:
If (e.Control) And (e.KeyCode = Keys.V) Then e.SuppressKeyPress = True
To prevent pasting for all text boxes on your form, set form KeyPreview to true and add the above code to form key down event.
-
August 3rd, 2009, 12:58 AM
#2
Re: Prevent Paste or Trap Paste into Edit Box
Thanx for sharing! 
What about the default context menu for textboxes, that allows you to paste ¿
-
August 3rd, 2009, 01:43 PM
#3
Re: Prevent Paste or Trap Paste into Edit Box
 Originally Posted by RoyK
Found how to do it:
In the key down event for a text or rich text box:
If (e.Control) And (e.KeyCode = Keys.V) Then e.SuppressKeyPress = True
To prevent pasting for all text boxes on your form, set form KeyPreview to true and add the above code to form key down event.
What if you have another control a form that requires a paste operation? How will you handle that?
-
August 3rd, 2009, 07:54 PM
#4
Re: Prevent Paste or Trap Paste into Edit Box
 Originally Posted by Shuja Ali
What if you have another control a form that requires a paste operation? How will you handle that?
I would add a either a menu item with a paste option or command button that allows you to paste.
-
August 4th, 2009, 01:24 PM
#5
Re: Prevent Paste or Trap Paste into Edit Box
 Originally Posted by RoyK
I would add a either a menu item with a paste option or command button that allows you to paste.
This is just out of curiosity, why would you disable a default behavior of a windows UI? Is there a specific functionality that you are building?
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
|