Add menu items to all instances of a form in a MDI.

This is my first project in VB.NET so this may seem like a newbie question, because it is!

I have a MDI form.  On this form there are multiple instances of frmA.  frmA has a menu called mnuSendTo.  mnuSendTo will have more items added to it as the program executes.  How can I add items to mnuSendTo so that all of the current frmA's and all of the future frmA's have the change


Answer this question

Add menu items to all instances of a form in a MDI.

  • philip1646

    Thanks for your reply.  Actually my solution was to put the menu on the MDI parent and just called it from each child.  Thanks for your input though.
  • Mr Fluffy

    one way is to use event for this purpose. let see .. your instance of formA , call this a1 is a member of the MDIParent, which in turn could have as many instace of formA, a2 , a3 etcc.., etc..

    this event will basically be registerd to all the formA instace and if a1 creat the menu it will triger the event  which is handlerd by the MDIParent, which in turn tells all a2, a3 ... about this thing..

    delegate void MenuCreatedHandler(object sender, MenuItem menu);
    ctor for MDIParent
    a1.MenuCreated += new MenuCreatedHandler(FormAMenuCreated);
    a2.MenuCreated += new MenuCreatedHandler(FormAMenuCreated);
    a3.MenuCreated += new MenuCreatedHandler(FormAMenuCreated);


    in FormAMenuCreated
    if( sender != a1)
     a1.CreateMenu(menu)
    ..
    ..



    while in formA 
    declare the event 
    public event MenuCreatedHandler MenuCreated;

    and when menu is created;
    if(MenuCreated != null)
    MenuCreated(this, mynewMenuItem);





    regards
    erymuzuan mustapa

  • Add menu items to all instances of a form in a MDI.