Click here to Skip to main content
15,034,598 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i disable copy paste in textbox in window application.Plz help me
Posted

   
v2
Comments
sofia3 18-Jun-12 6:28am
   
i dont want my textbox to be in read only ..i want that user can input watsoever values but he cant use copy paste ..plz help
use this code

C#
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button.ToString().ToLower()=="right")
    {
    SendKeys.Send("{Esc}");
    }
}
   
Comments
sofia3 18-Jun-12 6:18am
   
its not working:(
You have to apply on which textbox.In Form Load event,You can use this code-

textBox1.ContextMenu = new ContextMenu();
   
Comments
[no name] 18-Jun-12 8:20am
   
But still shortcuts (Ctrl&v) will work. See my solution 4.
sofia3 19-Jun-12 8:08am
   
thanks a lott rahul and idle63:)
Simply set the textbox property "ShortcutsEnabled" to false and you got it.
This way neither popup nor Ctrl&V will be accepted as textinput.

Regards.
   
v3
Comments
sofia3 19-Jun-12 8:08am
   
thanks a lotttt
[no name] 19-Jun-12 8:24am
   
You are welcome.
yaghob 11-Apr-16 4:10am
   
thank you sooo much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900