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

注解

是由类使用的从零开始的索引集合, 用于保存分配给ToolBarButton工具栏的所有控件。 ToolBar 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)

确定集合中是否包含具有指定键的 ToolBarButtonDetermines 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()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

ICollection.CopyTo(Array, Int32)

从特定的 ICollection 索引开始,将 Array 的元素复制到一个 Array 中。Copies 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.

适用于

另请参阅