build context menu from menu strip

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • parez

    build context menu from menu strip

    Hi,

    I build the menu strip using the designer.I want the context menu of
    the form to be same as the of children of one of the top leven Menu
    strip item.


    Items["actionToolStri pMenuItem"] gives me a ToolStripItem object but
    it does not have a hierarchy, no parents no children.

    How do i do this in c#?

    I tried

    this.ContextMen uStrip.Items.Ad dRange(Menu.Ite ms.Find("action ToolStripMenuIt em",true));

    but that line removes it from the menustrip and adds it to context
    menu



    TIA
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: build context menu from menu strip

    parez,

    Well, you can always create a new instance of the menu item, and then
    add it to the context menu. Also, the menu item should have an Items
    property which represents the children menu items on a sub menu.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "parez" <psawant@gmail. comwrote in message
    news:d70caa18-31af-4e45-8b67-46878fdab98c@a7 0g2000hsh.googl egroups.com...
    Hi,
    >
    I build the menu strip using the designer.I want the context menu of
    the form to be same as the of children of one of the top leven Menu
    strip item.
    >
    >
    Items["actionToolStri pMenuItem"] gives me a ToolStripItem object but
    it does not have a hierarchy, no parents no children.
    >
    How do i do this in c#?
    >
    I tried
    >
    this.ContextMen uStrip.Items.Ad dRange(Menu.Ite ms.Find("action ToolStripMenuIt em",true));
    >
    but that line removes it from the menustrip and adds it to context
    menu
    >
    >
    >
    TIA

    Comment

    • parez

      #3
      Re: build context menu from menu strip

      On Jun 2, 12:24 pm, "Nicholas Paldino [.NET/C# MVP]"
      <m...@spam.guar d.caspershouse. comwrote:
      parez,
      >
      Well, you can always create a new instance of the menu item, and then
      add it to the context menu. Also, the menu item should have an Items
      property which represents the children menu items on a sub menu.
      >
      --
      - Nicholas Paldino [.NET/C# MVP]
      - m...@spam.guard .caspershouse.c om
      >
      "parez" <psaw...@gmail. comwrote in message
      >
      news:d70caa18-31af-4e45-8b67-46878fdab98c@a7 0g2000hsh.googl egroups.com...
      >
      Hi,
      >
      I build the menu strip using the designer.I want the context menu of
      the form to be same as the of children of one of the top leven Menu
      strip item.
      >
      Items["actionToolStri pMenuItem"] gives me a ToolStripItem object but
      it does not have a hierarchy, no parents no children.
      >
      How do i do this in c#?
      >
      I tried
      >
      this.ContextMen uStrip.Items.Ad dRange(Menu.Ite ms.Find("action ToolStripMenuIt em",true));
      >
      but that line removes it from the menustrip and adds it to context
      menu
      >
      TIA

      ToolStripItem actionItem = Menu.Items["actionToolStri pMenuItem"];

      actionItem does not have Items property.

      Comment

      Working...