ToolBar.ToolBarButtonCollection 類別

定義

封裝 ToolBarButton 控制項集合,以供 ToolBar 類別使用。

public: ref class ToolBar::ToolBarButtonCollection : System::Collections::IList
public class ToolBar.ToolBarButtonCollection : System.Collections.IList
type ToolBar.ToolBarButtonCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class ToolBar.ToolBarButtonCollection
Implements IList
繼承
ToolBar.ToolBarButtonCollection
實作

範例

下列程式碼範例會建立和初始化 和 三 ToolBarButtonToolBar 控制項。 工具列按鈕會指派給工具列,並將工具列新增至表單。 此程式碼需要 Form 已經建立 。

public:
   void InitializeMyToolBar()
   {
      // Create and initialize the ToolBarButton controls and ToolBar.
      ToolBar^ 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 ToolBar to the Form.
      Controls->Add( toolBar1 );
   }
public void InitializeMyToolBar()
 {
    // Create and initialize the ToolBarButton controls and ToolBar.
    ToolBar 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 ToolBar to the Form.
    Controls.Add(toolBar1);
 }
Public Sub InitializeMyToolBar()
    ' Create and initialize the ToolBarButton controls and ToolBar.
    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 ToolBar to the Form.
    Controls.Add(toolBar1)
End Sub

備註

ToolBar.ToolBarButtonCollection是 類別用來 ToolBar 保存指派給工具列之所有 ToolBarButton 控制項之以零起始的索引集合。 Add使用 方法來新增個別按鈕和 Remove 方法來刪除它們。 Clear呼叫 方法,從集合中移除所有按鈕。

建構函式

ToolBar.ToolBarButtonCollection(ToolBar)

初始化 ToolBar.ToolBarButtonCollection 類別的新執行個體,並將它指派給指定的工具列。

屬性

Count

取得工具列按鈕集合中的按鈕數。

IsReadOnly

取得值,表示集合是否為唯讀。

Item[Int32]

取得或設定在工具列按鈕集合的指定索引處的工具列按鈕。

Item[String]

從集合中取得具有指定索引鍵的 ToolBarButton

方法

Add(String)

使用指定的 Text 屬性值將新的工具按鈕加入至工具列按鈕集合的結尾。

Add(ToolBarButton)

將指定的工具列按鈕加入工具列按鈕集合的結尾。

AddRange(ToolBarButton[])

將工具列按鈕的集合加入至這個工具列按鈕集合。

Clear()

將所有按鈕從工具列按鈕集合中移除。

Contains(ToolBarButton)

判斷指定的工具列按鈕是否為集合的成員。

ContainsKey(String)

判斷具有指定索引鍵的 ToolBarButton 是否包含在集合中。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

傳回可用來全面重複工具列按鈕集合的列舉值。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(ToolBarButton)

擷取集合中指定工具列按鈕的索引。

IndexOfKey(String)

擷取第一個具有指定索引鍵的 ToolBarButton 之索引。

Insert(Int32, ToolBarButton)

在指定位置的工具列按鈕集合中插入現有工具列按鈕。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(ToolBarButton)

將指定按鈕從工具列按鈕集合中移除。

RemoveAt(Int32)

將指定按鈕從工具列按鈕集合中移除。

RemoveByKey(String)

從集合中移除具有指定索引鍵的 ToolBarButton

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從特定的 ICollection 索引開始,將 Array 的項目複製到 Array

ICollection.IsSynchronized

取得值,表示是否同步化存取集合 (執行緒安全)。

ICollection.SyncRoot

取得可用來對按鈕的集合進行同步存取的物件。

IList.Add(Object)

將指定的工具列按鈕加入工具列按鈕集合的結尾。

IList.Contains(Object)

判斷此集合是否包含特定的值。

IList.IndexOf(Object)

決定集合中指定項目的索引。

IList.Insert(Int32, Object)

在指定位置的工具列按鈕集合中插入現有工具列按鈕。

IList.IsFixedSize

取得值,這個值表示集合的大小是否是固定的。

IList.Item[Int32]

取得或設定位在指定索引的項目。

IList.Remove(Object)

從集合移除第一個項目。

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱