.ControlCollection .Remove Method
Removes the specified control from the control collection.
public virtual void Remove(
is removed from the control collection, all subsequent controls are moved up one position in the collection. Control
You can also remove a
by using the Control method, or remove all controls by using the RemoveAt method. Clear
To add new
objects to the collection, use the Control or Add methods. AddRange Notes to Inheritors
in a derived class, be sure to call the base class's Remove method to ensure that the control is removed from the collection. Remove
The following code example removes a
from the Control of the derived class Control .ControlCollection if it is a member of the collection. The example requires that you have created a Panel , a Panel , and one or more Button controls on a RadioButton . The Form controls are added to the RadioButton control, and the Panel control is added to the Panel . When the button is clicked, the radio button named Form radioButton2 is removed from the . Control .ControlCollection
// Remove the RadioButton control if it exists.
private void removeButton_Click( object sender, System.EventArgs e)
Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0
.NET Framework Client Profile
Supported in: 4, 3.5 SP1
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see
.NET Framework System Requirements.