ToolBar.ToolBarButtonCollection.RemoveAt(Int32) 方法

定義

將指定按鈕從工具列按鈕集合中移除。

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 在集合中的索引位置。

實作

例外狀況

index 值小於零,或大於集合中的按鈕數。

範例

下列程式碼範例會移除 上的最後 ToolBarButton 一個 ToolBar 。 要移除之工具列按鈕的索引值會設定為等於 Count 屬性減一,因為 ToolBarButton 集合是以零起始的索引。

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

備註

方法 RemoveToolBarButton 移除 中指定位置的 ToolBar.ToolBarButtonCollection 。 如果您想要從集合中移除所有 ToolBarButton 控制項,請使用 Clear 方法。

適用於

另請參閱