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)

确定集合中是否包含具有指定键的 ToolBarButtonDetermines 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 的浅表副本。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 的元素复制到一个 Array 中。Copies 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.

扩展方法

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.

适用于

另请参阅