We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Dynamically adding item to parent menu, from child.

In an MDI application, I''d like some code in a child form to dynamically add a menu item to an existing menu popup on the parent form''s menu. For a variety of reasons, I can''t use the childformbarmanager for this purpose, so I would like to do it programmatically (instead of relying on the merge capabilities). Once I get a reference to the parent form''s bar manager, I think I''m set, but I''m wondering if there''s an especially clean, efficient (or recommended?) way to get that reference from the parent form. Both forms are currently in the same project, but the child form doesn''t know anything about its parent form at design time, so this doesn''t work: this.mdiparent.mainformbarmanager I know I could modify the child form so that its constructor receives a reference to the bar manager, but this seems overly clumsy. In any case, I''m new to working with the XPMenus and the Essential Tools, so I''d be interested in hearing what others recommend for this type of need. Regards, JD

3 Replies

AD Administrator Syncfusion Team December 12, 2003 01:38 PM UTC

Hi JD, Here is a sample which demonstrates how menus in MDI Child forms can be dynamically added and merged. Check the Form2_Entered() and Form2_Left() sections of the code in Form2 including the comments for more details. Regards, Arun


JD J Donnici December 12, 2003 02:27 PM UTC

Hi Arun, Thanks for the example... I''m wondering if it''s possible to do this without the child form having its own ChildFrameBarManager. It wouldn''t be the end of the world if I need to use it, but I''d like the child form to be able to add to the parent menu directly without another child bar manager instance. Thanks again, JD >Hi JD, > >Here is a sample which demonstrates how menus in MDI Child forms can be dynamically added and merged. > >Check the Form2_Entered() and Form2_Left() sections of the code in Form2 including the comments for more details. > >Regards, >Arun >


AD Administrator Syncfusion Team December 12, 2003 08:15 PM UTC

Hi JD, The attached sample shows how menus and toolbars can be created in code within a UserControl, for example, and then exported to a Form''s menu-structure in which it will be hosted. Kindly take a look at the sample.txt file. Unlike our MDI-menu merging, where child menus appear/disappear as the child form becomes active/ inactive, this one is a one-time merge and export of the menu-structure from the UserControl to the Form. Regards, Arun

Loader.
Live Chat Icon For mobile
Up arrow icon