none
Inheriting the contextmenustrip problem

    Question

  • I searched through the contextmenustrip questions and didn't see this one:

    We have a base form that has a context menu strip on it where we put a few common features (we made the menu and the menu items protected friend).  Then we have a form that inherits the base form and we are extending the menu.  It shows a few problems:
    1.  When you try to set properties on the menu itself they are all disabled as if it was scoped wrong to be able to change.
    2.  When you look at the code you notice that none of the designer code for adding the menu items to the strip (the addrange method) is there so your menu items wind up disappearing from the form. 

    I manually added code in the designer to add my new items to the menustrip, however at some point along the way the designer didn't like my code much and tossed it :|

    Thank you,

    Phil
    Friday, June 17, 2005 12:31 PM

Answers

  • Visual inheritance is intentionally disabled for the ToolStrip family of controls. We just simply did not have the budget to revamp the engineering around visual inheritance to properly support collection based controls. Your only workaround is runtime code to populate these items in derived forms. It'll be something on our list of considerations for next time.
    Friday, July 15, 2005 10:03 PM

All replies

  • I would venture to guess this is a bug in the designer.  You shouldn't be able to add items to the inherited context menu (just as you can't add items to inherited toolstrips or menus).

    As for adding code in the designer, don't do that.  The IDE regenerates this section during design time work.  Add your items after the form has been initialized (i.e., not in the constructor, but in Form_Load or the like).

    Friday, June 17, 2005 8:02 PM
  • Visual inheritance is intentionally disabled for the ToolStrip family of controls. We just simply did not have the budget to revamp the engineering around visual inheritance to properly support collection based controls. Your only workaround is runtime code to populate these items in derived forms. It'll be something on our list of considerations for next time.
    Friday, July 15, 2005 10:03 PM
  • Is there any update as to when this issue will be fixed?
    Tuesday, February 21, 2006 4:38 PM
  • I am also running into the same problem.  Is there any update (yet) on when this issue will be resolved?

    The only workaround that I have found is to use the old MainMenu (instead of the MenuStrip) and manually call the MainMenu.Merge( baseMenu ).

    Thanks.
    Friday, March 02, 2007 8:54 PM
  • any updates?

    i tried adding an toolstrip handler using code but i get the same error.

    btw i'm using VS2005 with vb
    Does .Net 3 have the same problem?
    Tuesday, March 27, 2007 9:14 AM
  • So far I see no change in VS2008.  Any comments?
    Rich

    Thursday, November 29, 2007 7:18 PM