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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to associate a PopupMenu with a control for context menu-like behavior

 

The PopupMenusManager lets you easily associate a PopupMenu with a control:

Through Designer

Once you drop a PopupMenusManager onto your form, you will see an extended "ContextMenu" property on all your controls. Set the property to the PopupMenu you just created. This will show the popup menu whenever you right-click on the control during run-time.

If you want to show a popup menu during some other event, read below for instructions to manually display the popup.

Through Code

You can use the PopupMenusManager to associate a PopupMenu with a control as follows:

C#

this.popupMenusManager1.SetContextMenu(this.treeViewAdv1, this.popupMenu1);

VB

Me.popupMenusManager1.SetContextMenu(Me.treeViewAdv1, Me.popupMenu1)

Instead, you could show the popup menu manually, as follows:

C#

private void MouseClickedHandler(object sender, System.Windows.Forms.MouseEventArgs e)

if(e.Button == MouseButtons.Right)

this.popupMenu1.Show((Control)sender, new Point(e.X, e.Y));

}

VB

Private Sub TreeViewAdv1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeViewAdv1.MouseClick

If e.Button = Windows.Forms.MouseButtons.Right Then

Me.PopupMenu1.Show(CType(sender, Control), New Point(e.X, e.Y))

End If

End Sub

Sample:

http://help.syncfusion.com/support/samples/kb/Tools.Windows/Tppmanager/Popupmanager.zip

Article ID: Published Date: Last Revised Date: Platform: Control:
1133 04/30/2011 07/10/2014 WinForms XPToolbar
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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