ToolBar.ToolBarButtonCollection.RemoveAt(Int32) 方法

定义

从工具栏按钮集合中移除给定按钮。Removes a given button from the toolbar button collection.

public:
 virtual void RemoveAt(int index);
public void RemoveAt (int index);
abstract member RemoveAt : int -> unit
override this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

参数

index
Int32

集合中 ToolBarButton 的索引位置。The indexed location of the ToolBarButton in the collection.

实现

例外

index 值小于零或大于集合中按钮的数目。The index value is less than 0, or it is greater than the number of buttons in the collection.

示例

下面的代码示例移除中的最后一个 ToolBarButton ToolBarThe following code example removes the last ToolBarButton on a ToolBar. Count由于 ToolBarButton 集合是从零开始的索引,因此要移除的工具栏按钮的索引值被设置为等于属性减一。The index value of the toolbar button being removed is set equal to the Count property, minus one, since the ToolBarButton collection is a zero-based index.

public:
   void RemoveMyButton()
   {
      int btns;
      btns = toolBar1->Buttons->Count;
      
      // Remove the last toolbar button.
      toolBar1->Buttons->RemoveAt( btns - 1 );
   }
public void RemoveMyButton()
 {
    int btns;
    btns = toolBar1.Buttons.Count;
 
    // Remove the last toolbar button.
    toolBar1.Buttons.RemoveAt(btns - 1);
 }
   
Public Sub RemoveMyButton()
    Dim btns As Integer
    btns = toolBar1.Buttons.Count
    
    ' Remove the last toolbar button.
    toolBar1.Buttons.RemoveAt(btns - 1)
End Sub

注解

Remove方法移除 ToolBarButton 中指定位置的 ToolBar.ToolBarButtonCollectionThe Remove method removes the ToolBarButton at the specified location in the ToolBar.ToolBarButtonCollection. 如果要删除集合中的所有 ToolBarButton 控件,请使用 Clear 方法。If you want to remove all ToolBarButton controls from the collection, use the Clear method.

适用于

另请参阅