共用方式為


Shape.ContextMenuStrip 屬性

取得或設定ContextMenuStrip線條或圖形控制項相關聯。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

'宣告
<BrowsableAttribute(True)> _
Public Overridable Property ContextMenuStrip As ContextMenuStrip
[BrowsableAttribute(true)]
public virtual ContextMenuStrip ContextMenuStrip { get; set; }
[BrowsableAttribute(true)]
public:
virtual property ContextMenuStrip^ ContextMenuStrip {
    ContextMenuStrip^ get ();
    void set (ContextMenuStrip^ value);
}
[<BrowsableAttribute(true)>]
abstract ContextMenuStrip : ContextMenuStrip with get, set
[<BrowsableAttribute(true)>]
override ContextMenuStrip : ContextMenuStrip with get, set
function get ContextMenuStrip () : ContextMenuStrip 
function set ContextMenuStrip (value : ContextMenuStrip)

屬性值

類型:ContextMenuStrip
ContextMenuStrip控制項,或為 null 參考 (Nothing中Visual Basic) 是否有任何ContextMenuStrip指派。The default is a null reference (Nothing in Visual Basic).

備註

如果ContextMenu也已指派給控制項,ContextMenu屬性會優先於ContextMenuStrip屬性。

範例

下列範例會顯示ContextMenuStrip指派給OvalShape控制按一下且放開滑鼠按鈕時。 此程式碼需要您具有FormOvalShape在其上的控制項。 它也是必要的OvalShapeContextMenuStrip指派給其ContextMenuStrip屬性。

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
        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));
            }
        }

.NET Framework 安全性

請參閱

參考

Shape 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)

Line 和 Shape 控制項簡介 (Visual Studio)