ControlCollection.RemoveAt(Int32) 方法

定義

在指定索引位置,從 ControlCollection 物件移除子控制項。

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

參數

index
Int32

要從集合移除之伺服器控制項的循序索引。

例外狀況

範例

下列程式碼範例會 RemoveAt 使用 方法來從 myButton 伺服器控制項中刪除子控制項。 方法呼叫會先指定 1 的索引位置,從中刪除控制項。 然後,此範例會寫入包含頁面的文字訊息,指出該位置的 ControlCollection 控制項已從集合中刪除。

// Use the RemoveAt method to delete the child control
// at index location 1.           
myButton.Controls.RemoveAt(1);
msgRemoveAt.Text = "The control at index location 1 has been removed.";
' Use the RemoveAt method to delete the child control
' at index location 1.           
myButton.Controls.RemoveAt(1)
msgRemoveAt.Text = "The control at index location 1 has been removed."

備註

若要根據其值從集合中移除控制項,請使用 Remove 方法。

適用於

另請參閱