Mar 16, 2006 #1 TerDavis Technical User Joined Sep 18, 2002 Messages 36 Location US Hi, I have a textbox that i don't want users to be able to use the Ctrl-V (Paste) feature to enter information. So, how do i prevent users from pasting text into a text box ? Thanks, Ter
Hi, I have a textbox that i don't want users to be able to use the Ctrl-V (Paste) feature to enter information. So, how do i prevent users from pasting text into a text box ? Thanks, Ter
Mar 16, 2006 #2 JurkMonkey Programmer Joined Nov 23, 2004 Messages 1,731 Location CA Capture the Keydown event then check if V is being pressed with the Control modifier txtBox1.KeyDown += blahblah private void txtBox1_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyData == Keys.V) && (e.Modifiers.Control)) { e.Handled = true; //Cancel the keypress } } Upvote 0 Downvote
Capture the Keydown event then check if V is being pressed with the Control modifier txtBox1.KeyDown += blahblah private void txtBox1_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyData == Keys.V) && (e.Modifiers.Control)) { e.Handled = true; //Cancel the keypress } }
Mar 16, 2006 #3 rdgerken Technical User Joined Jul 8, 2002 Messages 108 You might have to trap the right click too? Just a thought. Upvote 0 Downvote
Mar 16, 2006 #4 B00gyeMan Programmer Joined Jan 14, 2004 Messages 259 Location RO Yes, you have to "trap" the mouse also. Here's how you can do that: Code: ContextMenu aDummyCtxMenu = new ContextMenu(); aTextBox1.ContextMenu = aDummyCtxMenu; aTextBox2.ContextMenu = aDummyCtxMenu; aTextBox3.ContextMenu = aDummyCtxMenu; (repeat for all the text boxes you need) Upvote 0 Downvote
Yes, you have to "trap" the mouse also. Here's how you can do that: Code: ContextMenu aDummyCtxMenu = new ContextMenu(); aTextBox1.ContextMenu = aDummyCtxMenu; aTextBox2.ContextMenu = aDummyCtxMenu; aTextBox3.ContextMenu = aDummyCtxMenu; (repeat for all the text boxes you need)