ContextMenu.Show 메서드

정의

지정된 위치에 바로 가기 메뉴를 표시합니다.

오버로드

Show(Control, Point)

지정된 위치에 바로 가기 메뉴를 표시합니다.

Show(Control, Point, LeftRightAlignment)

지정된 맞춤을 사용하여 지정된 위치에 바로 가기 메뉴를 표시합니다.

Show(Control, Point)

지정된 위치에 바로 가기 메뉴를 표시합니다.

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
Control

이 바로 가기 메뉴가 연결된 컨트롤을 지정하는 Control입니다.

pos
Point

메뉴가 표시될 좌표를 지정하는 Point입니다. 이 좌표는 control 매개 변수에서 지정된 컨트롤의 클라이언트 좌표에 대한 상대 좌표로 지정됩니다.

예외

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)

지정된 맞춤을 사용하여 지정된 위치에 바로 가기 메뉴를 표시합니다.

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)

매개 변수

control
Control

이 바로 가기 메뉴가 연결된 컨트롤을 지정하는 Control입니다.

pos
Point

메뉴가 표시될 좌표를 지정하는 Point입니다. 이 좌표는 control 매개 변수에서 지정된 컨트롤의 클라이언트 좌표에 대한 상대 좌표로 지정됩니다.

alignment
LeftRightAlignment

pos 매개 변수에 상대적인 컨트롤의 맞춤을 지정하는 LeftRightAlignment입니다.

적용 대상