ToolBar.ToolBarButtonCollection.Item[] プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コレクション内の 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 の名前。
プロパティ値
Name プロパティが指定したキーと一致するToolBarButton。
注釈
Name プロパティは、ToolBar.ToolBarButtonCollection内のToolBarButtonのキーに対応します。
キーの比較では、大文字と小文字は区別されません。
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 。
例外
index 値は nullです。
例
次のコード例では、ツール バーの最後のツール バー ボタンを置き換えます。 このコードでは、 ToolBar と少なくとも 1 つの ToolBarButton が作成されている必要があります。 この例では、ツール バーのボタンの数を取得し、最後のボタンを新しく作成したボタンに置き換えます。
ToolBarButton コレクションは 0 から始まるインデックスであるため、置き換えられるツール バー ボタンのindex値は、Count プロパティから 1 を引いた値に設定されます。
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 から始まるインデックスです。