ToolBar.ToolBarButtonCollection.Item[] 속성

정의

컬렉션에 있는 ToolBarButton을 가져오거나 설정합니다.

오버로드

Item[String]

지정된 키를 가진 ToolBarButton을 컬렉션에서 가져옵니다.

Item[Int32]

도구 모음 단추 컬렉션에서 지정된 인덱스 위치에 있는 도구 모음 단추를 가져오거나 설정합니다.

Item[String]

지정된 키를 가진 ToolBarButton을 컬렉션에서 가져옵니다.

public:
 virtual property System::Windows::Forms::ToolBarButton ^ default[System::String ^] { System::Windows::Forms::ToolBarButton ^ get(System::String ^ key); };
public virtual System.Windows.Forms.ToolBarButton this[string key] { get; }
member this.Item(string) : System.Windows.Forms.ToolBarButton
Default Public Overridable ReadOnly Property Item(key As String) As ToolBarButton

매개 변수

key
String

검색할 ToolBarButton의 이름입니다.

속성 값

ToolBarButton

ToolBarButton 속성이 지정된 키와 일치하는 Name입니다.

설명

Name 키에 해당 하는 속성을 ToolBarButtonToolBar.ToolBarButtonCollection합니다.

키 비교는 대/소문자 구분 하지 않습니다. 매개 변수가 key null 또는 빈 문자열이면 .를 Item[] 반환합니다 null.

적용 대상

Item[Int32]

도구 모음 단추 컬렉션에서 지정된 인덱스 위치에 있는 도구 모음 단추를 가져오거나 설정합니다.

public:
 virtual property System::Windows::Forms::ToolBarButton ^ default[int] { System::Windows::Forms::ToolBarButton ^ get(int index); void set(int index, System::Windows::Forms::ToolBarButton ^ value); };
public virtual System.Windows.Forms.ToolBarButton this[int index] { get; set; }
member this.Item(int) : System.Windows.Forms.ToolBarButton with get, set
Default Public Overridable Property Item(index As Integer) As ToolBarButton

매개 변수

index
Int32

컬렉션에 포함된 ToolBarButton의 인덱싱된 위치입니다.

속성 값

ToolBarButton

지정한 인덱스 위치의 도구 모음 단추를 나타내는 ToolBarButton입니다.

예외

index 값이 null입니다.

index 값이 0보다 작은 경우

또는 index 값이 해당 컬렉션에 있는 단추의 수보다 크고 단추의 컬렉션이 null이 아닌 경우

예제

다음 코드 예제에서는 도구 모음의 마지막 도구 모음 단추를 바꿉니다. 이 코드를 사용하려면 하나 ToolBar 이상의 ToolBarButton 코드가 생성되어야 합니다. 이 예제에서는 도구 모음의 단추 수를 가져오고 마지막 단추를 새로 만든 단추로 바꿉니다. index 대체되는 도구 모음 단추의 값은 컬렉션이 0부터 시작하는 인덱스이므로 속성에서 ToolBarButton 1을 뺀 값으로 설정 Count 됩니다.

void ReplaceMyToolBarButton()
{
   int btns;
   btns = toolBar1->Buttons->Count;
   ToolBarButton^ toolBarButton1 = gcnew ToolBarButton;
   toolBarButton1->Text = "myButton";
   
   // Replace the last ToolBarButton in the collection.
   toolBar1->Buttons[ btns - 1 ] = toolBarButton1;
}
public void ReplaceMyToolBarButton()
 {
    int btns;
    btns = toolBar1.Buttons.Count;
    ToolBarButton toolBarButton1 = new ToolBarButton();
    toolBarButton1.Text = "myButton";
 
    // Replace the last ToolBarButton in the collection.
    toolBar1.Buttons[btns - 1] = toolBarButton1;
 }
Public Sub ReplaceMyToolBarButton()
    Dim btns As Integer
    btns = toolBar1.Buttons.Count
    Dim toolBarButton1 As New ToolBarButton()
    toolBarButton1.Text = "myButton"
    
    ' Replace the last ToolBarButton in the collection.
    toolBar1.Buttons(btns - 1) = toolBarButton1
End Sub

설명

컨트롤을 특정 위치에 할당 ToolBarButton 하거나 해당 위치에서 검색 ToolBar.ToolBarButtonCollection하려면 특정 인덱스 값으로 컬렉션 개체를 참조할 수 있습니다. 인덱스 값을 ToolBar.ToolBarButtonCollection 인덱스가 0부터 시작 합니다.

추가 정보

적용 대상