By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,324 Members | 537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,324 IT Pros & Developers. It's quick & easy.

How to disable Form's Context menu in C# windows forms

P: 46
language using: C#.

platform for program: WINDOWS FORM

I wnt to disable the right click for text boxes.And also want to diable the context menu.

I have already disable the Minimize and maximizsed buttons from the form properties and set the form border style to fix dialog but still on right click of mouse, the context menu for close and move is cming.
Jan 29 '08 #1
Share this Question
Share on Google+
5 Replies

radcaesar
Expert 100+
P: 759
To prevent the default context menu of a TextBox from showing up, assign it as empty

textBox1.ContextMenu = new ContextMenu();
Jan 29 '08 #2

Plater
Expert 5K+
P: 7,872
Remove the control box from the form and you won't get the close/move context menu. I have never seen it come from a right-click though.

You could also try setting a custom empty context menu to the form and such?
Jan 29 '08 #3

P: 46
Remove the control box from the form and you won't get the close/move context menu. I have never seen it come from a right-click though.

You could also try setting a custom empty context menu to the form and such?
Thnks a lot.Its working for textbox.But when i was trying to apply same method to disable the context menu of the form,this method is not working..why so??

this.ContextMenu = new ContextMenu();

Is there any other way to disable form's ContextMenu?
Jan 30 '08 #4

P: 46
language using: C#.

platform for program: WINDOWS FORM

This method of assigning empty context menu is not working for Form ,why so?
textbox.ContextMenu = new ContextMenu ();

I have tried as below

this.ContextMenu = new ContextMenu ();

But its not wrking

Do you know any method to disable context menu of from?
Jan 30 '08 #5

Plater
Expert 5K+
P: 7,872
EDIT: Please don't double post, you already had the question here.

My forms don't have a context menu, so I am unsure what you are getting at.
They have a controlbox menu though, which I think you can disable by changing the formborderstyle (and maybe the same way you do with max/min)
Jan 30 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.