ToolBar.ToolBarButtonCollection 類別

定義

封裝 ToolBarButton 控制項的集合來提供給 ToolBar 類別使用。Encapsulates a collection of ToolBarButton controls for use by the ToolBar class.

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
實作

範例

下列程式碼範例會建立和初始化ToolBar和三ToolBarButton個控制項。The following code example creates and initializes a ToolBar and three ToolBarButton controls. 工具列按鈕會指派給工具列, 而工具列會新增至表單。The toolbar buttons are assigned to the toolbar and the toolbar is added to the form. 此程式碼需要已Form建立的。This code requires that a Form has already been created.

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由類別用來保存指派ToolBarButton給工具列的所有控制項。 ToolBar.ToolBarButtonCollectionThe ToolBar.ToolBarButtonCollection is a zero-based indexed collection used by the ToolBar class to hold all the ToolBarButton controls assigned to the toolbar. 使用方法來新增個別按鈕Remove和方法, 以將它們刪除。 AddUse the Add method to add individual buttons and the Remove method to delete them. Clear呼叫方法, 以移除集合中的所有按鈕。Call the Clear method to remove all the buttons from the collection.

建構函式

ToolBar.ToolBarButtonCollection(ToolBar)

初始化 ToolBar.ToolBarButtonCollection 類別的新執行個體,並將它指派給指定的工具列。Initializes a new instance of the ToolBar.ToolBarButtonCollection class and assigns it to the specified toolbar.

屬性

Count

取得工具列按鈕集合中的按鈕數。Gets the number of buttons in the toolbar button collection.

IsReadOnly

取得值,表示集合是否為唯讀。Gets a value indicating whether the collection is read-only.

Item[Int32]

取得或設定在工具列按鈕集合的指定索引處的工具列按鈕。Gets or sets the toolbar button at the specified indexed location in the toolbar button collection.

Item[String]

從集合中取得具有指定索引鍵的 ToolBarButtonGets a ToolBarButton with the specified key from the collection.

方法

Add(String)

使用指定的 Text 屬性值將新的工具按鈕加入至工具列按鈕集合的結尾。Adds a new toolbar button to the end of the toolbar button collection with the specified Text property value.

Add(ToolBarButton)

將指定的工具列按鈕加入工具列按鈕集合的結尾。Adds the specified toolbar button to the end of the toolbar button collection.

AddRange(ToolBarButton[])

將工具列按鈕的集合加入至這個工具列按鈕集合。Adds a collection of toolbar buttons to this toolbar button collection.

Clear()

將所有按鈕從工具列按鈕集合中移除。Removes all buttons from the toolbar button collection.

Contains(ToolBarButton)

判斷指定的工具列按鈕是否為集合的成員。Determines if the specified toolbar button is a member of the collection.

ContainsKey(String)

判斷具有指定索引鍵的 ToolBarButton 是否包含在集合中。Determines if a ToolBarButton with the specified key is contained in the collection.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()

傳回可用來全面重複工具列按鈕集合的列舉值。Returns an enumerator that can be used to iterate through the toolbar button collection.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(ToolBarButton)

擷取集合中指定工具列按鈕的索引。Retrieves the index of the specified toolbar button in the collection.

IndexOfKey(String)

擷取第一個具有指定索引鍵的 ToolBarButton 之索引。Retrieves the index of the first occurrence of a ToolBarButton with the specified key.

Insert(Int32, ToolBarButton)

在指定位置的工具列按鈕集合中插入現有工具列按鈕。Inserts an existing toolbar button in the toolbar button collection at the specified location.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(ToolBarButton)

將指定按鈕從工具列按鈕集合中移除。Removes a given button from the toolbar button collection.

RemoveAt(Int32)

將指定按鈕從工具列按鈕集合中移除。Removes a given button from the toolbar button collection.

RemoveByKey(String)

從集合中移除具有指定索引鍵的 ToolBarButtonRemoves the ToolBarButton with the specified key from the collection.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從特定的 ICollection 索引開始,將 Array 的項目複製到 ArrayCopies the elements of the ICollection to an Array, starting at a particular Array index.

ICollection.IsSynchronized

取得值,表示是否同步化存取集合 (執行緒安全)。Gets a value indicating whether access to the collection is synchronized (thread safe).

ICollection.SyncRoot

取得可用來對按鈕的集合進行同步存取的物件。Gets an object that can be used to synchronize access to the collection of buttons.

IList.Add(Object)

將指定的工具列按鈕加入工具列按鈕集合的結尾。Adds the specified toolbar button to the end of the toolbar button collection.

IList.Contains(Object)

判斷此集合是否包含特定的值。Determines whether the collection contains a specific value.

IList.IndexOf(Object)

決定集合中指定項目的索引。Determines the index of a specific item in the collection.

IList.Insert(Int32, Object)

在指定位置的工具列按鈕集合中插入現有工具列按鈕。Inserts an existing toolbar button in the toolbar button collection at the specified location.

IList.IsFixedSize

取得值,這個值表示集合的大小是否是固定的。Gets a value indicating whether the collection has a fixed size.

IList.Item[Int32]

取得或設定位在指定索引的項目。Gets or sets the item at a specified index.

IList.Remove(Object)

從集合移除第一個項目。Removes the first occurrence of an item from the collection.

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱