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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem with the dynamic menu construction in MDI child form.

Thread ID:





13266 Apr 23,2004 08:06 PM UTC Apr 28,2004 11:53 AM UTC WinForms 4
Tags: Tools
Andrew Skalkin
Asked On April 23, 2004 08:06 PM UTC

I think the problem will be best illustrated with the example. I have an MDI application. In its child form, part of the "View" menu is constructed in the following way: foreach (Viewer v in ViewerPlugins) { BarItem bi = new BarItem(v.Name, new EventHandler(addViewer_Click)); childFrameBarManager.Items.Add(bi); // pbi stands for "parentBarItem" pbiView.Items.Insert(pbiView.Items.IndexOf(biViewAddForm), bi); } Everything worked like a charm until we decided to add the "View" menu to the main form. After that, the dynamically constructed part disappeared from the menu for the obvious reason - the merged menu must have used the ParentBarItem "View" from the main form''s menu. My question is simple - is it possible to get it back without losing the luxury of automatic menu merging? Thanks! Andrew.

Administrator [Syncfusion]
Replied On April 26, 2004 03:33 PM UTC

Hi Andrew, I have created a sample application as per my understanding of your specifications above. Please refer to the sample and let me know if I have understood your problem correctly. If not, kindly modify the sample to show the problem that you are facing and send it back to us so that we could further investigate this issue. We appreciate your cooperation, and thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Andrew Skalkin
Replied On April 26, 2004 08:07 PM UTC

Hi Guru, >I have created a sample application as per my understanding of your specifications above. This sample application doesn''t have a merged menu. Attached is the modified example (I added the "Common View" category that exists in both main and child forms). Thanks! mdi_menus_7424.zip

Administrator [Syncfusion]
Replied On April 28, 2004 11:18 AM UTC

Hi Andrew, Thanks for the modified sample. I could see the above mentioned problem here. Once the menu merging occurs, BarItems cannot be added dynamically through the MainFrameBarManager or ChildFrameBarManager. I have consulted the development team in this regard, and will update as soon as I hear from them. We appreciate your patience, and thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Administrator [Syncfusion]
Replied On April 28, 2004 11:53 AM UTC

Hi Andrew, After having further investigated this issue, I would like to inform you that you would have to get hold of the merged ParentBarItem of the parent-child menus by invoking the GetMergedEquivalent method, and then dynamically add the BarItems to that one. Often in a MDI scenario, ParentBarItems created during design-time in the MDI Parent and MDI children are merged together (if satisfying the merge criteria) into a new ParentBarItem which will replace the original in the menu structure. Once replaced, changes made to the original ParentBarItem, like adding a new BarItem will not be reflected in the merged one. So, you should access the merged item directly to add child BarItems. The newly added BarItems will then stay until the merging is lost (could happen when a different child form gets activated, etc). So, the recommended way is to keep all the required BarItems in the mainform''s ParentBarItem right from the beginning, before the merge, and show/hide them as necessary (instead of adding/removing them). I have also modified your previous sample accordingly and have attached_it_here. Please refer to it and let me know if you need any other information. We appreciate your continued interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon