ControlCollection.RemoveAt Method
Removes a child control, at the specified index location, from the ControlCollection object.
[Visual Basic] Public Overridable Sub RemoveAt( _ ByVal index As Integer _ ) [C#] public virtual void RemoveAt( int index ); [C++] public: virtual void RemoveAt( int index ); [JScript] public function RemoveAt( index : int );
Parameters
- index
- The ordinal index of the server control to be removed from the collection.
Exceptions
| Exception Type | Condition |
|---|---|
| HttpException | Thrown if the ControlCollection object is read-only. |
Remarks
To remove a control from the collection based on its value, use the Remove method.
Example
[Visual Basic] The following example uses the RemoveAt method to delete a child control from the myButton server control. The method call first specifies an index location of 1 from which the control is deleted. The example then writes to the containing page a text message saying that the control at that location has been deleted from the ControlCollection.
[Visual Basic]
' 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."
[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
ControlCollection Class | ControlCollection Members | System.Web.UI Namespace | Controls | Remove