PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
disable context menu for text boxes
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
disable context menu for text boxes
![]() |
disable context menu for text boxes |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
If one right-clicks in a text box, a context menu is displayed with the usual options (cut, copy, paste et.c.). Is there any way to disable this? I have my own textbox like this: public class MyTextBox : System.Windows.Forms.TextBox { public MyTextBox() { this.ContextMenu = null; } .... } However, this doesn't work. It works fine for forms though (setting it to null removes the menu). Is there any other way to do it? Thanks, Henrik |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Set it to an empty context menu:
ContextMenu contextMenu1 = new ContextMenu(); textBox1.ContextMenu = contextMenu1; HTH; Eric Cadwell http://www.origincontrols.com |
|
|
|
#3 |
|
Guest
Posts: n/a
|
* "Henrik" <anonymous@discussions.microsoft.com> scripsit:
> If one right-clicks in a text box, a context menu is > displayed with the usual options (cut, copy, paste et.c.). > Is there any way to disable this? > I have my own textbox like this: > > public class MyTextBox : System.Windows.Forms.TextBox > { > public MyTextBox() > { > this.ContextMenu = null; > } > > .... > } > > However, this doesn't work. It works fine for forms though > (setting it to null removes the menu). Override the control's 'WndProc' and listen for 'WM_CONTEXTMENU'. -- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

