How can disable the context menu?

I have created a menu ContextMenu1, I hope the pop menu don't display in some situations, how I can do thinks!


private void ContextMenu1_Popup(object sender, System.EventArgs e)
{
if (condition==true)
{
// Don't pop the menu, how can do I
}
}



Answer this question

How can disable the context menu?

  • bljacobs

    In VS 2005 with ContextMenuStrips, handle the ContextMenuStrip.Opening event, which gives you a CancelEventArgs argument.  Set e.Cancel = true to cancel opening the ContextMenuStrip.
  • MasterG152

    What is the context menu binded to

    How about trying this:



    private void ContextMenu1_Popup(object sender, System.EventArgs e)

       if (condition==true
       { 
           contextMenu1.Visible = false;
       }
    }


     


  • How can disable the context menu?