ToolBarButton 클래스

정의

Windows 도구 모음 단추를 나타냅니다.

이 클래스는 .NET Core 3.1 이상 버전에서는 사용할 수 없습니다. 대신 ToolBarButton 컨트롤을 대체하고 확장하는 ToolStripButton을 사용합니다.

public ref class ToolBarButton : System::ComponentModel::Component
public class ToolBarButton : System.ComponentModel.Component
type ToolBarButton = class
    inherit Component
Public Class ToolBarButton
Inherits Component
상속

예제

다음 코드 예제는 ToolBar 및 3 ToolBarButton 컨트롤입니다. 도구 모음 단추는 단추 컬렉션에 할당 된, 컬렉션 도구 모음에 할당 하 고 도구 모음 폼에 추가 됩니다. 에 ButtonClick 이벤트 도구 모음에는 Button 의 속성은 ToolBarButtonClickEventArgs 평가 됩니다 적절 한 대화 상자를 연. 이 코드를 실행 하려면를 Form, OpenFileDialog, SaveFileDialog, 및 PrintDialog 모두 만들어야 합니다.

public:
   void InitializeMyToolBar()
   {
      // Create and initialize the ToolBar and ToolBarButton controls.
      toolBar1 = gcnew ToolBar;
      ToolBarButton^ toolBarButton1 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      
      // Set the Text properties of the ToolBarButton controls.
      toolBarButton1->Text = "Open";
      toolBarButton2->Text = "Save";
      toolBarButton3->Text = "Print";
      
      // Add the ToolBarButton controls to the ToolBar.
      toolBar1->Buttons->Add( toolBarButton1 );
      toolBar1->Buttons->Add( toolBarButton2 );
      toolBar1->Buttons->Add( toolBarButton3 );
      
      // Add the event-handler delegate.
      toolBar1->ButtonClick += gcnew ToolBarButtonClickEventHandler(
         this, &Form1::toolBar1_ButtonClick );
      
      // Add the ToolBar to the Form.
      Controls->Add( toolBar1 );
   }

private:
   void toolBar1_ButtonClick(
      Object^ sender,
      ToolBarButtonClickEventArgs^ e )
   {
      // Evaluate the Button property to determine which button was clicked.
      switch ( toolBar1->Buttons->IndexOf( e->Button ) )
      {
         case 0:
            openFileDialog1->ShowDialog();
            // Insert code to open the file.
            break;
         case 1:
            saveFileDialog1->ShowDialog();
            // Insert code to save the file.
            break;
         case 2:
            printDialog1->ShowDialog();
            // Insert code to print the file.    
            break;
      }
   }
public void InitializeMyToolBar()
 {
    // Create and initialize the ToolBar and ToolBarButton controls.
    toolBar1 = new ToolBar();
    ToolBarButton toolBarButton1 = new ToolBarButton();
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
 
    // Set the Text properties of the ToolBarButton controls.
    toolBarButton1.Text = "Open";
    toolBarButton2.Text = "Save";
    toolBarButton3.Text = "Print";
 
    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
    
    // Add the event-handler delegate.
    toolBar1.ButtonClick += new ToolBarButtonClickEventHandler (
       this.toolBar1_ButtonClick);
    
    // Add the ToolBar to the Form.
    Controls.Add(toolBar1);
 }
 
 private void toolBar1_ButtonClick (
                         Object sender, 
                         ToolBarButtonClickEventArgs e)
 {
   // Evaluate the Button property to determine which button was clicked.
   switch(toolBar1.Buttons.IndexOf(e.Button))
   {
      case 0:
         openFileDialog1.ShowDialog();
         // Insert code to open the file.
         break; 
      case 1:
         saveFileDialog1.ShowDialog();
         // Insert code to save the file.
         break; 
      case 2:
         printDialog1.ShowDialog();
         // Insert code to print the file.    
         break; 
    }
 }
Public Sub InitializeMyToolBar()
    ' Create and initialize the ToolBar and ToolBarButton controls.
    Dim toolBar1 As New ToolBar()
    Dim toolBarButton1 As New ToolBarButton()
    Dim toolBarButton2 As New ToolBarButton()
    Dim toolBarButton3 As New ToolBarButton()
    
    ' Set the Text properties of the ToolBarButton controls.
    toolBarButton1.Text = "Open"
    toolBarButton2.Text = "Save"
    toolBarButton3.Text = "Print"
    
    ' Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1)
    toolBar1.Buttons.Add(toolBarButton2)
    toolBar1.Buttons.Add(toolBarButton3)
    
    ' Add the event-handler delegate.
    AddHandler toolBar1.ButtonClick, AddressOf Me.toolBar1_ButtonClick
    
    ' Add the ToolBar to the Form.
    Controls.Add(toolBar1)
End Sub    

Private Sub toolBar1_ButtonClick(ByVal sender As Object, _
ByVal e As ToolBarButtonClickEventArgs)

    ' Evaluate the Button property to determine which button was clicked.
    Select Case toolBar1.Buttons.IndexOf(e.Button)
        Case 0
            openFileDialog1.ShowDialog()
            ' Insert code to open the file.
        Case 1
            saveFileDialog1.ShowDialog()
            ' Insert code to save the file.
        Case 2
            printDialog1.ShowDialog()
            ' Insert code to print the file.
    End Select
End Sub

설명

이 클래스는 .NET Core 3.1 이상 버전에서는 사용할 수 없습니다. 대신 ToolStripButton를 사용하세요.

ToolBarButton 컨트롤에 의해 부모로 지정 됩니다 ToolBar 컨트롤입니다. 도구 모음 단추를 만든 후에 설정 하려면 공용 속성은 TextImageIndex입니다. 설정 된 Text 텍스트 또는 이미지의 오른쪽 아래에 표시할 단추의 속성입니다. 단추에 이미지를 만들어서 할당할를 ImageList에 할당 합니다 ImageList 도구 모음의; 속성 이미지 인덱스 값을 할당 한 다음는 ImageIndex 단추의 속성입니다.

도구 모음에 할당 된 도구 모음 단추의 모양을 변경 하려면 설정의 Appearance 부모 도구 모음 컨트롤의 속성입니다. ToolBarAppearance.Flat 모양을 제공 단추를 평면 모양으로 표시 합니다. 마우스 포인터가 모양 변경 3 차원 단추 위로 이동 합니다. 단추 구분 기호 단추를 평면 모양으로 경우에 단추 사이의 공간이 아니라 선으로 표시 됩니다. 경우는 Appearance 속성이 ToolBarAppearance.Normal, 단추, 볼록하게 표시 및 구분 기호 사이의 단추 간격으로 표시 합니다.

할당할 수 있습니다는 ContextMenu 단추에 경우 합니다 Style 속성이 ToolBarButtonStyle.DropDown합니다. 단추를 클릭할 때 할당된 된 메뉴가 표시 됩니다.

컬렉션을 만드는 ToolBarButton 에서 표시 하는 컨트롤을 ToolBar, 단추를 사용 하 여 개별적으로 추가 합니다 Add 메서드의 Buttons 속성. 또는 사용 하 여 여러 도구 모음 단추를 추가할 수 있습니다는 AddRange 메서드.

생성자

ToolBarButton()

ToolBarButton 클래스의 새 인스턴스를 초기화합니다.

ToolBarButton(String)

ToolBarButton 클래스의 새 인스턴스를 초기화하고 할당된 텍스트를 단추에 표시합니다.

속성

CanRaiseEvents

구성 요소가 이벤트를 발생시킬 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
Container

IContainer을 포함하는 Component를 가져옵니다.

(다음에서 상속됨 Component)
DesignMode

Component가 현재 디자인 모드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
DropDownMenu

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

Enabled

단추를 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

Events

Component에 연결된 이벤트 처리기의 목록을 가져옵니다.

(다음에서 상속됨 Component)
ImageIndex

단추에 할당된 이미지의 인덱스 값을 가져오거나 설정합니다.

ImageKey

단추에 할당된 이미지의 이름을 가져오거나 설정합니다.

Name

단추의 이름입니다.

Parent

도구 모음 단추가 할당된 ToolBar 컨트롤을 가져옵니다.

PartialPush

토글 스타일 도구 모음 단추가 부분적으로 눌리는지 여부를 나타내는 값을 가져오거나 설정합니다.

Pushed

토글 스타일 도구 모음 단추가 현재 눌러진 상태에 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

Rectangle

도구 모음 단추의 경계 사각형을 가져옵니다.

Site

ComponentISite를 가져오거나 설정합니다.

(다음에서 상속됨 Component)
Style

도구 모음 단추의 스타일을 가져오거나 설정합니다.

Tag

도구 모음 단추에 대한 데이터가 들어 있는 개체를 가져오거나 설정합니다.

Text

도구 모음 단추에 표시되는 텍스트를 가져오거나 설정합니다.

ToolTipText

단추의 도구 설명으로 표시되는 텍스트를 가져오거나 설정합니다.

Visible

도구 모음 단추가 표시되는지 여부를 나타내는 값을 가져오거나 설정합니다.

메서드

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Dispose()

Component에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Component)
Dispose(Boolean)

ToolBarButton에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetService(Type)

Component 또는 해당 Container에서 제공하는 서비스를 나타내는 개체를 반환합니다.

(다음에서 상속됨 Component)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
ToString()

ToolBarButton 컨트롤을 나타내는 문자열을 반환합니다.

이벤트

Disposed

Dispose() 메서드를 호출하여 구성 요소를 삭제할 때 발생합니다.

(다음에서 상속됨 Component)

적용 대상

추가 정보