PC Review


Reply
Thread Tools Rate Thread

disable context menu for text boxes

 
 
Henrik
Guest
Posts: n/a
 
      10th Dec 2003
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

 
Reply With Quote
 
 
 
 
Eric Cadwell
Guest
Posts: n/a
 
      10th Dec 2003
Set it to an empty context menu:

ContextMenu contextMenu1 = new ContextMenu();
textBox1.ContextMenu = contextMenu1;

HTH;
Eric Cadwell
http://www.origincontrols.com


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      10th Dec 2003
* "Henrik" <(E-Mail Removed)> 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>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help - Create Context Menu for Text Boxes Kenny Microsoft Excel Programming 0 6th Nov 2008 03:24 AM
Context Menu (Sub-Menu Disable/Enable) =?Utf-8?B?SlJfMDYwNjIwMDU=?= Microsoft Excel Programming 4 31st Aug 2006 07:01 PM
Context menu from a set of check boxes =?Utf-8?B?SmF5?= Microsoft Dot NET Compact Framework 1 20th Apr 2006 03:24 PM
Disable Start Menu context menu? =?Utf-8?B?bW9pbmR5Y3Vicw==?= Microsoft Windows 2000 Group Policy 4 11th May 2005 11:46 PM
custom paste context menu fvor text boxes Dennis C. Drumm Microsoft C# .NET 9 12th Apr 2005 09:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:34 AM.