ContextMenu.Show メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ショートカット メニューを指定した位置に表示します。
オーバーロード
| 名前 | 説明 |
|---|---|
| Show(Control, Point) |
ショートカット メニューを指定した位置に表示します。 |
| Show(Control, Point, LeftRightAlignment) |
ショートカット メニューを指定した位置に表示し、指定した配置で表示します。 |
Show(Control, Point)
- ソース:
- ContextMenu.cs
- ソース:
- ContextMenu.cs
ショートカット メニューを指定した位置に表示します。
public:
void Show(System::Windows::Forms::Control ^ control, System::Drawing::Point pos);
public void Show(System.Windows.Forms.Control control, System.Drawing.Point pos);
member this.Show : System.Windows.Forms.Control * System.Drawing.Point -> unit
Public Sub Show (control As Control, pos As Point)
パラメーター
例外
control パラメーターはnull。
コントロールのハンドルが存在しないか、コントロールが表示されません。
例
次のコード例では、ショートカット メニューを作成し、 Show メソッドを使用する方法を示します。 この例を実行するには、Button1 という名前のボタンを含むフォームに次のコードを貼り付けます。 すべてのイベントがイベント処理メソッドに関連付けられていることを確認します。
// Displays the shortcut menu, offsetting its location
// from the upper-left corner of Button1 by 20 pixels in each direction.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
//Declare the menu items and the shortcut menu.
array<MenuItem^>^menuItems = {gcnew MenuItem( "Some Button Info" ),gcnew MenuItem( "Some Other Button Info" ),gcnew MenuItem( "Exit" )};
System::Windows::Forms::ContextMenu^ buttonMenu = gcnew System::Windows::Forms::ContextMenu( menuItems );
buttonMenu->Show( Button1, System::Drawing::Point( 20, 20 ) );
}
// Displays the shortcut menu, offsetting its location
// from the upper-left corner of Button1 by 20 pixels in each direction.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Declare the menu items and the shortcut menu.
MenuItem[] menuItems = new MenuItem[]{new MenuItem("Some Button Info"),
new MenuItem("Some Other Button Info"), new MenuItem("Exit")};
ContextMenu buttonMenu = new ContextMenu(menuItems);
buttonMenu.Show(Button1, new System.Drawing.Point(20, 20));
}
' Displays the shortcut menu, offsetting its location
' from the upper-left corner of Button1 by 20 pixels in each direction.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Declare the menu items and the shortcut menu.
Dim menuItems() As MenuItem = New MenuItem() _
{New MenuItem("Some Button Info"), _
New MenuItem("Some Other Button Info"), _
New MenuItem("Exit")}
Dim buttonMenu As New ContextMenu(menuItems)
buttonMenu.Show(Button1, New System.Drawing.Point(20, 20))
End Sub
注釈
通常、 ContextMenu は、 ContextMenu がバインドされているフォームのコントロールまたは領域でマウスの右ボタンをクリックすると表示されます。 このメソッドを使用すると、ショートカット メニューを特定の場所に手動で表示し、特定のコントロールにバインドできます。 このメソッドは、メニューが閉じるまで戻りません。
適用対象
Show(Control, Point, LeftRightAlignment)
- ソース:
- ContextMenu.cs
- ソース:
- ContextMenu.cs
ショートカット メニューを指定した位置に表示し、指定した配置で表示します。
public:
void Show(System::Windows::Forms::Control ^ control, System::Drawing::Point pos, System::Windows::Forms::LeftRightAlignment alignment);
public void Show(System.Windows.Forms.Control control, System.Drawing.Point pos, System.Windows.Forms.LeftRightAlignment alignment);
member this.Show : System.Windows.Forms.Control * System.Drawing.Point * System.Windows.Forms.LeftRightAlignment -> unit
Public Sub Show (control As Control, pos As Point, alignment As LeftRightAlignment)
パラメーター
- alignment
- LeftRightAlignment
LeftRightAlignment パラメーターに対するコントロールの配置を指定するpos。