ToolBar.ToolBarButtonCollection ToolBar.ToolBarButtonCollection ToolBar.ToolBarButtonCollection ToolBar.ToolBarButtonCollection Class

定義

封裝 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.ToolBarButtonCollectionToolBar.ToolBarButtonCollectionToolBar.ToolBarButtonCollectionToolBar.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.ToolBarButtonCollection是以零為起始的索引的集合,供ToolBar類別來保存所有ToolBarButton指派給工具列控制項。The ToolBar.ToolBarButtonCollection is a zero-based indexed collection used by the ToolBar class to hold all the ToolBarButton controls assigned to the toolbar. 使用Add方法中加入個別的按鈕和Remove方法來刪除它們。Use 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(ToolBar) ToolBar.ToolBarButtonCollection(ToolBar) ToolBar.ToolBarButtonCollection(ToolBar)

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

屬性

Count Count Count Count

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

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

Item[String] Item[String] Item[String] Item[String]

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

方法

Add(String) Add(String) Add(String) Add(String)

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

Add(ToolBarButton) Add(ToolBarButton) Add(ToolBarButton) Add(ToolBarButton)

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

AddRange(ToolBarButton[]) AddRange(ToolBarButton[]) AddRange(ToolBarButton[]) AddRange(ToolBarButton[])

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

Clear() Clear() Clear() Clear()

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

Contains(ToolBarButton) Contains(ToolBarButton) Contains(ToolBarButton) Contains(ToolBarButton)

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

ContainsKey(String) ContainsKey(String) ContainsKey(String) ContainsKey(String)

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
IndexOf(ToolBarButton) IndexOf(ToolBarButton) IndexOf(ToolBarButton) IndexOf(ToolBarButton)

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

IndexOfKey(String) IndexOfKey(String) IndexOfKey(String) IndexOfKey(String)

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

Insert(Int32, ToolBarButton) Insert(Int32, ToolBarButton) Insert(Int32, ToolBarButton) Insert(Int32, ToolBarButton)

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

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(ToolBarButton) Remove(ToolBarButton) Remove(ToolBarButton) Remove(ToolBarButton)

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

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

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

RemoveByKey(String) RemoveByKey(String) RemoveByKey(String) RemoveByKey(String)

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

ToString() ToString() ToString() ToString()

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

(Inherited from Object)

明確介面實作

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

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

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

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

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

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

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

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

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

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

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

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

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

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

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

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

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

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

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

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

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

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

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱