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

Programatically add submenu to context menu

Thread ID:

Created:

Updated:

Platform:

Replies:

100156 Jul 7,2011 01:02 PM Jul 14,2011 04:02 AM Windows Forms 8
loading
Tags: Tools
Thomas DiLello
Asked On July 7, 2011 01:02 PM

I am trying to programmatically add a submenu item to a context menu. I currently have the context menu working correctly but I would like to add another menu item to the context menu which already exists and add the ability to open a submenu item from the main context menu. Also, the new submenu needs to have a number of items with a checkbox next to each choice. If anyone can provide assistance that would be great, thanks.


Iniyen M A [Syncfusion]
Replied On July 8, 2011 04:13 AM

Hi Thomas,

Thanks for your interest in Syncfusion products.

You can achieve your requirement by enabling MenuItem's "CheckOnClick" property, which can make it behave like a CheckBox.

Please let us know if you need further assistance.

Regards,
Iniyen M.A.


Thomas DiLello
Replied On July 8, 2011 01:27 PM

What about creating subitems in a context menu? How do I do that?


Iniyen M A [Syncfusion]
Replied On July 11, 2011 01:27 AM

Hi Thomas,

Thanks for the update.

You can achieve your requirement by using the Specific ToolStripItem's DropDownItems.AddRange() method. For more information I have included the sample as follows, Kindly have a look on it.

[Sample]
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ContextMnustrpex_thrcode-1451971708.zip

Please let us know if you need further assistance.

We are glad to help you out.

Regards,
Iniyen M.A.


Thomas DiLello
Replied On July 11, 2011 11:21 AM

Hi, thanks for the update on this.

However, I am using BarItems instead of ToolStripMenu as that is what the project calls for. How can I use populate a BarItem with a submenu and display that in a sub context menu? Thanks.

Tom


Thomas DiLello
Replied On July 12, 2011 05:31 PM

Hello? Are you there?

I have figured out that I need to use a DropDownBarItem object. Now can you tell me how I can use this object to display submenu items? I have a menu item of type DropDownBarItem but the menu it displays is blank. I tried setting that class's PopupControlContainer property. I set that properties ContextMenuStrip property but I am not seeing anything on that menu. Here is how I build my submenu:

private PopupControlContainer BuildSubMenu()
{
ContextMenuStrip strip = new ContextMenuStrip();
strip.Items.AddRange(new[] {new ToolStripMenuItem("Sub menu Item#1")});

PopupControlContainer popupControlContainer = new PopupControlContainer
{ContextMenuStrip = strip, ParentControl = this};

return popupControlContainer;
}


Iniyen M A [Syncfusion]
Replied On July 13, 2011 07:26 AM

Hi Thomas,

Thanks for the update.

We do not have support to have BarItems in ContextMenuStripEx.

Please let us know if you need further assistance.

Regards,
Iniyen M.A.



Thomas DiLello
Replied On July 13, 2011 10:25 AM

Hi,

Could you tell me more about PopupControlContainer. I am setting the PopupControlContainer property on a DropDownBarItem. How do I display list of menu items in a PopupControlContainer?

Thanks


Vallarasu S [Syncfusion]
Replied On July 14, 2011 04:02 AM

Hi Thomas,

Thanks for the update.

You should use ParentBarItems in place of BarItem where a list of child BarItems needs to be shown, and Checked property of the BarItem can be toggled upon click to make it behave like a checkBox.

I have attached a sample to demonstrate how PopupMenu can be associated with a control. Refer the sample and let me know if this helps.

PopupControlContainer is intended to host objects of type 'Control', and is not the best way to implement popup menus.

Regards
Vallarasu S.



ContextMenuSample_aef47e4.zip

CONFIRMATION

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.

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.

;