Dynamically adding menu items to a merged menu
How to correctly add a menu item to a merged menu? I'm doing it the following way (see below) but, apparently, it results in two similar menu items being added. It used to work fine in v 4.1
Attached is an example demonstrating the problem (click on "View->New", then on "Add Menu Item")
private static BarItem FindByText(IList items, string text)
{
foreach (BarItem b in items)
{
// ignore the "&" symbol
if (b.Text.Replace("&", "") == text.Replace("&", "")) return b;
}
return null;
}
private void barItem2_Click(object sender, EventArgs e)
{
Bar mergedMainMenu = mainMenu.Manager.GetMergedEquivalent(mainMenu, mainMenu);
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Items, "View");
BarItem item = new BarItem("foo");
pbi.Manager.Items.Add(item);
pbi.Items.Add(item);
}
ClosingFloatingWindow1.zip
Attached is an example demonstrating the problem (click on "View->New", then on "Add Menu Item")
private static BarItem FindByText(IList items, string text)
{
foreach (BarItem b in items)
{
// ignore the "&" symbol
if (b.Text.Replace("&", "") == text.Replace("&", "")) return b;
}
return null;
}
private void barItem2_Click(object sender, EventArgs e)
{
Bar mergedMainMenu = mainMenu.Manager.GetMergedEquivalent(mainMenu, mainMenu);
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Items, "View");
BarItem item = new BarItem("foo");
pbi.Manager.Items.Add(item);
pbi.Items.Add(item);
}
ClosingFloatingWindow1.zip
SIGN IN To post a reply.
10 Replies
AD
Administrator
Syncfusion Team
December 7, 2006 08:32 PM UTC
By the way, there is one more very irritating thing: if you have several toolbars on your form (SdiForm in my case), their designer-time positions do not get persisted. Every time we open it in form designer, they are positioned in the top-left corner of the _screen_ on top of each other. Of course this is not critical since those positions play no role in runtime, just thought I'd let you know about it.
GS
Gopalakrishnan S
Syncfusion Team
December 8, 2006 01:42 AM UTC
Hi Andrew,
We really regret for the inconvenience caused. We were able to see the issue. We are currently working on this issue. We will update the details on Monday.
Thank you using Syncfusion products.
Regards,
S.Gopal.
We really regret for the inconvenience caused. We were able to see the issue. We are currently working on this issue. We will update the details on Monday.
Thank you using Syncfusion products.
Regards,
S.Gopal.
GS
Gopalakrishnan S
Syncfusion Team
December 12, 2006 01:51 AM UTC
Hi Andrew,
Sorry for the getting back to you. I have tried a workaround for this.However,that has not worked successfully.I am still looking into the source to find some other way to help you out. Meanwhile I will go ahead and log a bug report so that we can address this issue at the earliest.
Here is the code snippet :
this.mainFrameBarManager1.UnregisterMdiChildTypes(new Type[] { typeof(SdiForm) });
Bar mergedMainMenu = mainMenu.Manager.GetMergedEquivalent(mainMenu, mainMenu);
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Items, "View");
BarItem item = new BarItem("foo");
pbi.Manager.Items.Add(item);
pbi.Items.Add(item);
mainFrameBarManager1.RegisterMdiChildTypes(new Type[] { typeof(SdiForm) });
Best Regards,
S.Gopal.
Sorry for the getting back to you. I have tried a workaround for this.However,that has not worked successfully.I am still looking into the source to find some other way to help you out. Meanwhile I will go ahead and log a bug report so that we can address this issue at the earliest.
Here is the code snippet :
this.mainFrameBarManager1.UnregisterMdiChildTypes(new Type[] { typeof(SdiForm) });
Bar mergedMainMenu = mainMenu.Manager.GetMergedEquivalent(mainMenu, mainMenu);
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Items, "View");
BarItem item = new BarItem("foo");
pbi.Manager.Items.Add(item);
pbi.Items.Add(item);
mainFrameBarManager1.RegisterMdiChildTypes(new Type[] { typeof(SdiForm) });
Best Regards,
S.Gopal.
GS
Gopalakrishnan S
Syncfusion Team
December 22, 2006 04:48 PM UTC
Hi Andrew,
We regret for the inconvenience caused. I have logged a bug report # 3225 regarding this issue. Please track the status of this bug in the link below.
Defect #3225 - When adding a barItem in MergedMenu two baritems added.
We will fix this issue at the earliest and keep you informed.
Thanks for bringing this issue to our attention.
Regards,
S.Gopal.
We regret for the inconvenience caused. I have logged a bug report # 3225 regarding this issue. Please track the status of this bug in the link below.
Defect #3225 - When adding a barItem in MergedMenu two baritems added.
We will fix this issue at the earliest and keep you informed.
Thanks for bringing this issue to our attention.
Regards,
S.Gopal.
AD
Administrator
Syncfusion Team
January 5, 2007 05:37 PM UTC
Hi guys,
Do you plan to fix this bug any time soon? We have an upcoming release...
Regards,
Andrew
Do you plan to fix this bug any time soon? We have an upcoming release...
Regards,
Andrew
GS
Gopalakrishnan S
Syncfusion Team
January 5, 2007 06:47 PM UTC
Hi Andrew,
We are currently working on this issue. We have increased the priority of the defect. We will update the time frame needed to fix the issue after consulting with the development team.
Thanks,
S.Gopal.
We are currently working on this issue. We have increased the priority of the defect. We will update the time frame needed to fix the issue after consulting with the development team.
Thanks,
S.Gopal.
GS
Gopalakrishnan S
Syncfusion Team
January 12, 2007 12:34 AM UTC
Hi Andrew,
I am sorry for the wrong information displayed. Please use the following code snippet:
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Manager.Items, "View");
instead of,
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Items, "View");
Please let me know if this works.
Thanks,
S.Gopal.
I am sorry for the wrong information displayed. Please use the following code snippet:
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Manager.Items, "View");
instead of,
ParentBarItem pbi = (ParentBarItem)FindByText(mergedMainMenu.Items, "View");
Please let me know if this works.
Thanks,
S.Gopal.
AD
Administrator
Syncfusion Team
January 12, 2007 05:49 PM UTC
Hi S.Gopal,
First of all, thank you for your support!
The approach that you suggested worked on the submitted example; however, it might work incorrectly if there are menu items with the same name in other menu branches. The reason for that is that
mergedMainMenu.Items returns a collection of menu items located directly under mergedMainMenu (there are 3 of them in the example);
mergedMainMenu.Manager.Items returns a collection of menu items managed by the Manager (there are 7 of them in the example).
It looks like this example works fine whithout a call to GetMergedEquivalent, but will it work in more complex scenarios?
private void barItem2_Click(object sender, EventArgs e)
{
ParentBarItem pbi = (ParentBarItem)FindByText(mainMenu.Items, "View");
BarItem item = new BarItem("foo");
pbi.Manager.Items.Add(item);
pbi.Items.Add(item);
}
Thanks!
Andrew
First of all, thank you for your support!
The approach that you suggested worked on the submitted example; however, it might work incorrectly if there are menu items with the same name in other menu branches. The reason for that is that
mergedMainMenu.Items returns a collection of menu items located directly under mergedMainMenu (there are 3 of them in the example);
mergedMainMenu.Manager.Items returns a collection of menu items managed by the Manager (there are 7 of them in the example).
It looks like this example works fine whithout a call to GetMergedEquivalent, but will it work in more complex scenarios?
private void barItem2_Click(object sender, EventArgs e)
{
ParentBarItem pbi = (ParentBarItem)FindByText(mainMenu.Items, "View");
BarItem item = new BarItem("foo");
pbi.Manager.Items.Add(item);
pbi.Items.Add(item);
}
Thanks!
Andrew
AD
Administrator
Syncfusion Team
January 12, 2007 05:56 PM UTC
>It looks like this example works fine whithout a call to GetMergedEquivalent, but will it work in more complex scenarios?
Opps of course it won't work if the parent bar item comes from an SDI form :(
Opps of course it won't work if the parent bar item comes from an SDI form :(
GS
Gopalakrishnan S
Syncfusion Team
January 12, 2007 11:07 PM UTC
Hi Andrew,
Currently,our developer is working on this and we will be addressing this issue at the earliest.
Thanks for your patience.
Best Regards,
S.Gopal.
Currently,our developer is working on this and we will be addressing this issue at the earliest.
Thanks for your patience.
Best Regards,
S.Gopal.
SIGN IN To post a reply.
- 10 Replies
- 2 Participants
-
AD Administrator
- Dec 7, 2006 08:28 PM UTC
- Jan 12, 2007 11:07 PM UTC