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 该方法。

适用于

另请参阅