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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neehakale
    New Member
    • Aug 2007
    • 46

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

    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.
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    To prevent the default context menu of a TextBox from showing up, assign it as empty

    textBox1.Contex tMenu = new ContextMenu();

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      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?

      Comment

      • neehakale
        New Member
        • Aug 2007
        • 46

        #4
        Originally posted by Plater
        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.ContextMen u = new ContextMenu();

        Is there any other way to disable form's ContextMenu?

        Comment

        • neehakale
          New Member
          • Aug 2007
          • 46

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

          language using: C#.

          platform for program: WINDOWS FORM

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

          I have tried as below

          this.ContextMen u = new ContextMenu ();

          But its not wrking

          Do you know any method to disable context menu of from?

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            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)

            Comment

            Working...