ToolBarButton.DropDownMenu 속성

정의

드롭다운 도구 모음 단추에 표시할 메뉴를 가져오거나 설정합니다.

public:
 property System::Windows::Forms::Menu ^ DropDownMenu { System::Windows::Forms::Menu ^ get(); void set(System::Windows::Forms::Menu ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))]
public System.Windows.Forms.Menu DropDownMenu { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))>]
member this.DropDownMenu : System.Windows.Forms.Menu with get, set
Public Property DropDownMenu As Menu

속성 값

Menu

드롭다운 도구 모음 단추에 표시할 ContextMenu입니다. 기본값은 null입니다.

특성

예외

할당된 개체가 ContextMenu가 아닌 경우

예제

다음 코드 예제는 ToolBar 및 3 ToolBarButton 제어 단추 도구 모음에 할당 하 고 단추의 공용 속성 중 일부를 설정 합니다. 이 코드를 실행 하려면를 ImageList, ToolTipForm 만들어진 및 ImageList 에 하나 이상의 Image 할당 되도록 합니다.

public:
   void InitializeMyToolBar()
   {
      // Create the ToolBar, ToolBarButton controls, and menus.
      ToolBarButton^ toolBarButton1 = gcnew ToolBarButton( "Open" );
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      ToolBar^ toolBar1 = gcnew ToolBar;
      MenuItem^ menuItem1 = gcnew MenuItem( "Print" );
      array<MenuItem^>^ temp1 = {menuItem1};
      System::Windows::Forms::ContextMenu^ contextMenu1 =
         gcnew System::Windows::Forms::ContextMenu( temp1 );
      
      // Add the ToolBarButton controls to the ToolBar.
      toolBar1->Buttons->Add( toolBarButton1 );
      toolBar1->Buttons->Add( toolBarButton2 );
      toolBar1->Buttons->Add( toolBarButton3 );
      
      // Assign an ImageList to the ToolBar and show ToolTips.
      toolBar1->ImageList = imageList1;
      toolBar1->ShowToolTips = true;
      
      /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
         Style properties of the ToolBarButton controls. */
      toolBarButton2->Style = ToolBarButtonStyle::Separator;
      toolBarButton3->Text = "Print";
      toolBarButton3->Style = ToolBarButtonStyle::DropDownButton;
      toolBarButton3->ToolTipText = "Print";
      toolBarButton3->ImageIndex = 0;
      toolBarButton3->DropDownMenu = contextMenu1;
      
      // Add the ToolBar to a form.
      Controls->Add( toolBar1 );
   }
public void InitializeMyToolBar()
 {
    // Create the ToolBar, ToolBarButton controls, and menus.
    ToolBarButton toolBarButton1 = new ToolBarButton("Open");
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
    ToolBar toolBar1 = new ToolBar();
    MenuItem menuItem1 = new MenuItem("Print");
    ContextMenu contextMenu1 = new ContextMenu(new MenuItem[]{menuItem1});

    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
 
    // Assign an ImageList to the ToolBar and show ToolTips.
    toolBar1.ImageList = imageList1;
    toolBar1.ShowToolTips = true;
 
    /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
       Style properties of the ToolBarButton controls. */
    toolBarButton2.Style = ToolBarButtonStyle.Separator;
    toolBarButton3.Text = "Print";
    toolBarButton3.Style = ToolBarButtonStyle.DropDownButton;
    toolBarButton3.ToolTipText = "Print";
    toolBarButton3.ImageIndex = 0;
    toolBarButton3.DropDownMenu = contextMenu1;
 
    // Add the ToolBar to a form.
    Controls.Add(toolBar1);
 }
Public Sub InitializeMyToolBar()
    ' Create the ToolBar, ToolBarButton controls, and menus.
    Dim toolBarButton1 As New ToolBarButton("Open")
    Dim toolBarButton2 As New ToolBarButton()
    Dim toolBarButton3 As New ToolBarButton()
    Dim toolBar1 As New ToolBar()
Dim menuItem1 As New MenuItem("Print")
Dim contextMenu1 As New ContextMenu(New MenuItem(){menuItem1})
    
    ' Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1)
    toolBar1.Buttons.Add(toolBarButton2)
    toolBar1.Buttons.Add(toolBarButton3)
    
    ' Assign an ImageList to the ToolBar and show ToolTips.
    toolBar1.ImageList = imageList1
    toolBar1.ShowToolTips = True
    
    ' Assign ImageIndex, ContextMenu, Text, ToolTip, and
    ' Style properties of the ToolBarButton controls. 
    toolBarButton2.Style = ToolBarButtonStyle.Separator
    toolBarButton3.Text = "Print"
    toolBarButton3.Style = ToolBarButtonStyle.DropDownButton
    toolBarButton3.ToolTipText = "Print"
    toolBarButton3.ImageIndex = 0
    toolBarButton3.DropDownMenu = contextMenu1
    
    ' Add the ToolBar to a form.
    Controls.Add(toolBar1)
End Sub

설명

지정할 수는 ContextMenu 드롭다운 단추를 클릭할 때 표시 될 있습니다. 이 속성이 사용 되지 않는 한 합니다 Style 속성 값으로 설정 됩니다 ToolBarButtonStyle.DropDownButton합니다.

참고

하지만 DropDownMenu 속성으로 정의 됩니다를 Menu 유형을 할당 해야는 ContextMenu 제대로 표시 되도록 합니다. 만드는 경우 사용자 고유의 MenuItem 파생 클래스에 개체를 할당 해야 합니다는 ContextMenu 할당를 ContextMenuDropDownMenu 속성입니다.

적용 대상

추가 정보