Control.ContextMenu プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Overridable Property ContextMenu As ContextMenu
Dim instance As Control Dim value As ContextMenu value = instance.ContextMenu instance.ContextMenu = value
public virtual ContextMenu ContextMenu { get; set; }
public: virtual property ContextMenu^ ContextMenu { ContextMenu^ get (); void set (ContextMenu^ value); }
/** @property */ public ContextMenu get_ContextMenu () /** @property */ public void set_ContextMenu (ContextMenu value)
public function get ContextMenu () : ContextMenu public function set ContextMenu (value : ContextMenu)
コントロールに関連付けられたショートカット メニューを表す ContextMenu。

ショートカット メニューは、ユーザーがコントロールを右クリックすると、コンテキストに固有なメニュー オプションがユーザーに表示されるようにするために使用されます。
継承時の注意 派生クラスで ContextMenu プロパティをオーバーライドする場合は、基本クラスの ContextMenu プロパティを使用して、基本の実装を拡張します。それ以外の場合は、すべての実装を提供する必要があります。ContextMenu プロパティの get アクセサと set アクセサの両方をオーバーライドする必要はありません。必要に応じて 1 つのアクセサだけをオーバーライドできます。
マウスの右ボタンが押されて離されたときに、TreeView に割り当てられている ContextMenu を表示するコード例を次に示します。このコードでは、TreeView を持つ Form が存在している必要があります。また、TreeView には、その ContextMenu プロパティに ContextMenu が割り当てられていることも必要です。
Private Sub treeView1_MouseUp(sender As Object, _ e As MouseEventArgs) Handles treeView1.MouseUp ' If the right mouse button was clicked and released, ' display the shortcut menu assigned to the TreeView. If e.Button = MouseButtons.Right Then treeView1.ContextMenu.Show(treeView1, New Point(e.X, e.Y)) End If End Sub
private void treeView1_MouseUp(object sender, MouseEventArgs e) { // If the right mouse button was clicked and released, // display the shortcut menu assigned to the TreeView. if(e.Button == MouseButtons.Right) { treeView1.ContextMenu.Show(treeView1, new Point(e.X, e.Y) ); } }
private: void treeView1_MouseUp( Object^ /*sender*/, MouseEventArgs^ e ) { // If the right mouse button was clicked and released, // display the shortcut menu assigned to the TreeView. if ( e->Button == ::MouseButtons::Right ) { treeView1->ContextMenu->Show( treeView1, Point(e->X,e->Y) ); } }
private void treeView1_MouseUp(Object sender, MouseEventArgs e) { // If the right mouse button was clicked and released, // display the shortcut menu assigned to the TreeView. if (e.get_Button().Equals(get_MouseButtons().Right)) { treeView1.get_ContextMenu().Show(treeView1, new Point(e.get_X() , e.get_Y())); } } //treeView1_MouseUp

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.ContextMenu プロパティを検索する場合は、下記のリンクをクリックしてください。

- Control.ContextMenu プロパティのページへのリンク