Context Menu on a ToolStripMenuItem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • in10se
    New Member
    • Jun 2007
    • 4

    Context Menu on a ToolStripMenuItem

    I am trying to mimic the functionality of a web browser's "Favorites" (or "Bookmarks" ) menu. I would like to be able to right-click on a ToolStripMenuIt em and have a context menu appear so that I can list options such as "Open Page", "Delete Favorite", "Delete Folder", etc. Unfortunately the ToolStripMenuIt em does not have a "ContextMen u" property like many other object in the System.Windows. Forms namespace.

    If it was a TextBox, I would just create my context menu in the IDE and set the TextBox.Context Menu to my menu and it would work, but that does not appear to be an option for ToolStrip objects.

    Is there still some way that I can bring up a context menu that can reference the properties of the selected menu item?

    I am coding in C# in .NET 2.0.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    The toolstrip itself has a contextmenustri p option

    Comment

    • Vidhura
      New Member
      • May 2007
      • 99

      #3
      Hope the following helps
      ContextMenuStri p contextMenuStri p1 = new ContextMenuStri p();
      contextMenuStri p1.Items.AddRan ge(new System.Windows. Forms.ToolStrip Item[] {
      menuItem1ToolSt ripMenuItem,
      menuItem2ToolSt ripMenuItem,
      menuItem3ToolSt ripMenuItem});


      menuStrip1.Cont extMenuStrip = contextMenuStri p1;

      Comment

      Working...