ContextMenu.Show 메서드

정의

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

오버로드

Name Description
Show(Control, Point)

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

Show(Control, Point, LeftRightAlignment)

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

Show(Control, Point)

Source:
ContextMenu.cs
Source:
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
Control

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

pos
Point

Point 메뉴를 표시할 좌표를 지정하는 A입니다. 이러한 좌표는 매개 변수에 지정된 컨트롤의 클라이언트 좌표를 기준으로 지정됩니다 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)

Source:
ContextMenu.cs
Source:
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)

매개 변수

control
Control

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

pos
Point

Point 메뉴를 표시할 좌표를 지정하는 A입니다. 이러한 좌표는 매개 변수에 지정된 컨트롤의 클라이언트 좌표를 기준으로 지정됩니다 control .

alignment
LeftRightAlignment

LeftRightAlignment 매개 변수를 기준으로 컨트롤의 맞춤을 지정하는 pos A입니다.

적용 대상