locked
How to Merge ContextMenuStrip Items into MenuStrip item as subitems? RRS feed

  • Question

  • Hi,

    How to merge ContextMenuStrip items into MenuStrip Item as it's SubItems?

    let say I got ContextMenuStrip : Do1
                                                   Do2

    and I got MenuStrip item : Edit

    So, after merging I wonna Get:  Edit
                                                  ------
                                                   Do1
                                                   Do2

    How to do that?

    Thanks..
    • Edited by gb_007 Sunday, July 12, 2009 11:10 PM
    Sunday, July 12, 2009 9:27 PM

Answers

  • Hi gb_007,

    Based on my test, Nishant Sivakumar's solution is correct. menuStrip1.Items[0] refer to the first root menu item in your menuStrip1. That mean the "Edit" item should be the first root menu item.

    If the "Edit" is the sub menu item. You should right click it to view its name, If the name is EditToolStripMenuItem, then merge the contextmenuitem to it like this.
    EditToolStripMenuItem.DropDown = contextMenuStrip1;

    Sincerely,
    Kira Qian
    Please mark the replies as answers if they help and unmark if they don't.
    • Marked as answer by gb_007 Wednesday, July 15, 2009 9:24 AM
    Tuesday, July 14, 2009 7:29 AM

All replies

  • How to do that using --> ToolStripManager

    thanks..
    Monday, July 13, 2009 12:05 AM
  • Plz help me,

    It's very important to me...

    Thanks..
    Monday, July 13, 2009 7:39 AM
  • Hello...

    Plz dont ignore me,

    And help me with my question..

    Thanks..
    Monday, July 13, 2009 4:40 PM
  • Set the DropDown property of the Edit menu tool-strip item to the context menu strip.
    http://blog.voidnish.com
    Monday, July 13, 2009 4:56 PM
  • HowTo?

    the ContextMenuStrip is found in the MdiParent form,

    and the MenuStrip is found in the MdiChild form, Which I open and I wonna merge those two menus...

    What to do?

    did this: menuStrip1.Items[0].

    what next?

    Monday, July 13, 2009 4:59 PM
  • Plz,

    try to help me with that,

    and finish it already,

    Dont ignore me...

    Thanks..
    Monday, July 13, 2009 7:44 PM
  • HowTo?

    the ContextMenuStrip is found in the MdiParent form,

    and the MenuStrip is found in the MdiChild form, Which I open and I wonna merge those two menus...

    What to do?

    did this: menuStrip1.Items[0].

    what next?


    Something like :

    menuStrip1.Items[0].DropDown = contentMenuStrip;
    http://blog.voidnish.com
    Monday, July 13, 2009 7:46 PM
  • Well,

    That something... Not working.  --->  menuStrip1.Items[0].DropDown = contentMenuStrip;

    What else to do?

    Monday, July 13, 2009 8:01 PM
  • Perhaps you need to do a cast there. What error do you get?
    http://blog.voidnish.com
    Monday, July 13, 2009 8:12 PM
  • Try :

    ((ToolStripMenuItem)menuStrip1.Items[0]).DropDown = contextMenuStrip1;

    http://blog.voidnish.com
    • Proposed as answer by Kira Qian Tuesday, July 14, 2009 7:13 AM
    Monday, July 13, 2009 8:27 PM
  • Got this error:

    Object reference not set to an instance of an object.

    How to deal with that?

    Monday, July 13, 2009 8:31 PM
  • What is the type of menuStrip1.Items[0] ?
    http://blog.voidnish.com
    Monday, July 13, 2009 8:33 PM
  • it sais  menuStrip1.Items[0]  type ---> System.Windows.Forms.ToolStripItem
    Monday, July 13, 2009 10:16 PM
  • Hi gb_007,

    Based on my test, Nishant Sivakumar's solution is correct. menuStrip1.Items[0] refer to the first root menu item in your menuStrip1. That mean the "Edit" item should be the first root menu item.

    If the "Edit" is the sub menu item. You should right click it to view its name, If the name is EditToolStripMenuItem, then merge the contextmenuitem to it like this.
    EditToolStripMenuItem.DropDown = contextMenuStrip1;

    Sincerely,
    Kira Qian
    Please mark the replies as answers if they help and unmark if they don't.
    • Marked as answer by gb_007 Wednesday, July 15, 2009 9:24 AM
    Tuesday, July 14, 2009 7:29 AM