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 、内のキー ToolBarButton に対応します ToolBar.ToolBarButtonCollection

キーの比較では、大文字と小文字は区別されません。 パラメーターがkey空または空の文字列の場合はnullnullItem[].

適用対象

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 少なくとも 1 つが 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 から始まるインデックスです。

こちらもご覧ください

適用対象