This documentation is archived and is not being maintained.

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 _
public virtual void RemoveAt(
 int index
public: virtual void RemoveAt(
 int index
public function RemoveAt(
   index : int


The ordinal index of the server control to be removed from the collection.


Exception Type Condition
HttpException Thrown if the ControlCollection object is read-only.


To remove a control from the collection based on its value, use the Remove method.


[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.           
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 Language Filter in the upper-left corner of the page.


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

ControlCollection Class | ControlCollection Members | System.Web.UI Namespace | Controls | Remove