Why there is no PopupMenu.AfterPopup method?
I'm adding some menu items to the existing popup menu in BeforePopup event handler and I want to remove them when the popup menu is closed, but there is no AfterPopup event. Can you suggest a workaround to this problem?
Maybe I'm doing the wrong thing? Basically, we have hundreds of so-called "actions". When user right-clicks on a grid, each action has a chance to add menu items to the popup menu, depending on a context. Since I don't want to recreate popup menu on every right click, I decided to dynamically add and remove those menu items (which is quite painful, btw). Is there a better approach?
Thanks!
Andrew
Maybe I'm doing the wrong thing? Basically, we have hundreds of so-called "actions". When user right-clicks on a grid, each action has a chance to add menu items to the popup menu, depending on a context. Since I don't want to recreate popup menu on every right click, I decided to dynamically add and remove those menu items (which is quite painful, btw). Is there a better approach?
Thanks!
Andrew
SIGN IN To post a reply.
5 Replies
AD
Administrator
Syncfusion Team
November 2, 2006 09:02 PM UTC
Hi Andrew,
The PopupMenu does not have "AfterPopup" or any other similar Events. But the ParentBarItem has "PopupClosed" Event which can be used to remove the Items from the PopupMenu.
Add new BarItems to the PopupMenu in the PopupMenu's "BeforePopup" event and remove those items in the PopupMenu's ParentBarItem "Popupclosed" event. Here is the code snippet for doing the same.
BarItem b1 = new BarItem();
void popupMenu1_BeforePopup(object sender, Syncfusion.Windows.Forms.CancelMouseEventArgs e)
{
if (popupMenu1.GetPopupParentControl() == gradientPanel2)
{
b1.Text = "Newly Added";
b1.ID = "New";
parentBarItem1.Items.Add(b1);
}
}
private void parentBarItem1_PopupClosed(object sender, EventArgs e)
{
parentBarItem1.Items.Remove(b1);
}
I have attached a sample. Hope this is what you actually needed.
PopupEvents.zip
Best Regards,
Purusothaman.R
The PopupMenu does not have "AfterPopup" or any other similar Events. But the ParentBarItem has "PopupClosed" Event which can be used to remove the Items from the PopupMenu.
Add new BarItems to the PopupMenu in the PopupMenu's "BeforePopup" event and remove those items in the PopupMenu's ParentBarItem "Popupclosed" event. Here is the code snippet for doing the same.
BarItem b1 = new BarItem();
void popupMenu1_BeforePopup(object sender, Syncfusion.Windows.Forms.CancelMouseEventArgs e)
{
if (popupMenu1.GetPopupParentControl() == gradientPanel2)
{
b1.Text = "Newly Added";
b1.ID = "New";
parentBarItem1.Items.Add(b1);
}
}
private void parentBarItem1_PopupClosed(object sender, EventArgs e)
{
parentBarItem1.Items.Remove(b1);
}
I have attached a sample. Hope this is what you actually needed.
PopupEvents.zip
Best Regards,
Purusothaman.R
AD
Administrator
Syncfusion Team
November 2, 2006 10:06 PM UTC
Yes, this is what I initially did but the PopupClosed event wasn't coming:
menu.BeforePopup = delegate { AddMenus(); } // works
menu.ParentBarItem.PopupClosed = delegate { RemoveMenues(); } // never got there
Oh probably the problem is that this popup menu is a merged popup menu... I'll try it.
Oops menu.ParentBarItem.Manager == null, is this by design?
menu.BeforePopup = delegate { AddMenus(); } // works
menu.ParentBarItem.PopupClosed = delegate { RemoveMenues(); } // never got there
Oh probably the problem is that this popup menu is a merged popup menu... I'll try it.
Oops menu.ParentBarItem.Manager == null, is this by design?
AD
Administrator
Syncfusion Team
November 3, 2006 12:27 AM UTC
I tried this again and now I'm getting the PopupClosed event... must have been some silly mistake. Sorry!
PR
Purusothaman R
Syncfusion Team
November 3, 2006 12:43 AM UTC
Hi Andrew,
PopupMenus can be used in two ways. The first one is by using the default ParentBarItem and by using a MainFrameBarManager.
If the "default ParentBarItem" is used, the PopupMenu.ParentBarItem.Manager will be null. It is by design. When using the later method, the MainFrameBarManager can be assigned to the ParentBarItem.Manager.
Which method do you use? Could you please send us a sample to show your actual need?
Thanks,
Purusothaman.R
PopupMenus can be used in two ways. The first one is by using the default ParentBarItem and by using a MainFrameBarManager.
If the "default ParentBarItem" is used, the PopupMenu.ParentBarItem.Manager will be null. It is by design. When using the later method, the MainFrameBarManager can be assigned to the ParentBarItem.Manager.
Which method do you use? Could you please send us a sample to show your actual need?
Thanks,
Purusothaman.R
AD
Administrator
Syncfusion Team
November 3, 2006 12:46 AM UTC
Hi Andrew,
Thanks for your update.
Ignore my previous update if the issue is solved.
Thanks,
Purusothaman.R
Thanks for your update.
Ignore my previous update if the issue is solved.
Thanks,
Purusothaman.R
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
AD Administrator
- Nov 1, 2006 11:52 PM UTC
- Nov 3, 2006 12:46 AM UTC