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:
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.
ADAdministrator Syncfusion Team December 12, 2003 08:38 AM
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.
JDJ DonniciDecember 12, 2003 09:27 AM
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.
>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.
ADAdministrator Syncfusion Team December 12, 2003 03:15 PM
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.