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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Why there is no PopupMenu.AfterPopup method?

Thread ID:





51284 Nov 1,2006 11:52 PM UTC Nov 3,2006 12:46 AM UTC WinForms 5
Tags: Tools
Administrator [Syncfusion]
Asked On November 1, 2006 11:52 PM UTC

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?


Administrator [Syncfusion]
Replied On 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";

private void parentBarItem1_PopupClosed(object sender, EventArgs e)

I have attached a sample. Hope this is what you actually needed.

Best Regards,

Administrator [Syncfusion]
Replied On 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?

Administrator [Syncfusion]
Replied On 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!

Purusothaman R [Syncfusion]
Replied On 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?


Administrator [Syncfusion]
Replied On November 3, 2006 12:46 AM UTC

Hi Andrew,

Thanks for your update.

Ignore my previous update if the issue is solved.



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

or the page will be automatically redirected to 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