Wednesday, February 4, 2009

Disable right click pop up on textbox in C# winform

It took me almost 3 hours to google the correct way to fix this one...

There are 2 ways of disabling right click on textbox in a C# winform.

1. create a new context menu and add it to the text box control :

TextBox textbox1 = new TextBox();
ContextMenu cm = new ContextMenu();
textbox1.controls.add(cm);

and you are done.

2. Just do
textbox1.ShortcutsEnabled = false;

second one is short and sweet....

No comments: