Shape.ContextMenuStrip Property
Gets or sets the ContextMenuStrip associated with a line or shape control.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
[BrowsableAttribute(true)]
public virtual ContextMenuStrip ContextMenuStrip { get; set; }
public:
[BrowsableAttribute(true)]
property ContextMenuStrip^ ContextMenuStrip {
virtual ContextMenuStrip^ get();
virtual void set(ContextMenuStrip^ value);
}
[<BrowsableAttribute(true)>]
abstract ContextMenuStrip : ContextMenuStrip with get, set
[<BrowsableAttribute(true)>]
override ContextMenuStrip : ContextMenuStrip with get, set
<BrowsableAttribute(True)>
Public Overridable Property ContextMenuStrip As ContextMenuStrip
Property Value
Type: System.Windows.Forms.ContextMenuStrip
The ContextMenuStrip for the control, or a null reference (Nothing in Visual Basic) if there is no ContextMenuStrip assigned. The default is a null reference (Nothing in Visual Basic).
Remarks
If a ContextMenu has also been assigned to the control, the ContextMenu property takes precedence over the ContextMenuStrip property.
Examples
The following example displays the ContextMenuStrip assigned to a OvalShape control when the right mouse button is clicked and released. This code requires that you have a Form with an OvalShape control on it. It is also required that the OvalShape has a ContextMenuStrip assigned to its ContextMenuStrip property.
private void ovalShape1_MouseUp(object sender, MouseEventArgs e)
{
// If the right mouse button is clicked and released,
// display the shortcut menu assigned to the TreeView.
if (e.Button == MouseButtons.Right)
{
ovalShape1.ContextMenuStrip.Show(this, new Point(e.X, e.Y));
}
}
Private Sub OvalShape1_MouseUp(
ByVal sender As Object,
ByVal e As MouseEventArgs
) Handles OvalShape1.MouseUp
' If the right mouse button is clicked and released,
' display the shortcut menu assigned to the TreeView.
If e.Button = MouseButtons.Right Then
OvalShape1.ContextMenuStrip.Show(Me, New Point(e.X, e.Y))
End If
End Sub
See Also
Shape Class
Microsoft.VisualBasic.PowerPacks Namespace
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)
Introduction to the Line and Shape Controls (Visual Studio)
Return to top