ControlCollection Class
Provides a collection container that enables ASP.NET server controls to maintain a list of their child controls.
Assembly: System.Web (in System.Web.dll)
System.Web.UI::ControlCollection
System.Web.UI::EmptyControlCollection
System.Web.UI.HtmlControls::HtmlTable::HtmlTableRowControlCollection
System.Web.UI.HtmlControls::HtmlTableRow::HtmlTableCellControlCollection
System.Web.UI.WebControls::Table::RowControlCollection
System.Web.UI.WebControls::TableRow::CellControlCollection
System.Web.UI.WebControls::ViewCollection
| Name | Description | |
|---|---|---|
![]() | ControlCollection(Control^) | Initializes a new instance of the ControlCollection class for the specified parent server control. |
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of server controls in the ControlCollection object for the specified ASP.NET server control. |
![]() | IsReadOnly | Gets a value indicating whether the ControlCollection object is read-only. |
![]() | IsSynchronized | Gets a value indicating whether the ControlCollection object is synchronized. |
![]() | Item[Int32] | Gets a reference to the server control at the specified index location in the ControlCollection object. |
![]() | Owner | Gets the ASP.NET server control to which the ControlCollection object belongs. |
![]() | SyncRoot | Gets an object that can be used to synchronize access to the collection of controls. |
| Name | Description | |
|---|---|---|
![]() | Add(Control^) | Adds the specified Control object to the collection. |
![]() | AddAt(Int32, Control^) | Adds the specified Control object to the collection at the specified index location. |
![]() | Clear() | Removes all controls from the current server control's ControlCollection object. |
![]() | Contains(Control^) | Determines whether the specified server control is in the parent server control's ControlCollection object. |
![]() | CopyTo(Array^, Int32) | Copies the child controls stored in the ControlCollection object to an System::Array object, beginning at the specified index location in the System::Array. |
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetEnumerator() | Retrieves an enumerator that can iterate through the ControlCollection object. |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | IndexOf(Control^) | Retrieves the index of a specified Control object in the collection. |
![]() | MemberwiseClone() | |
![]() | Remove(Control^) | Removes the specified server control from the parent server control's ControlCollection object. |
![]() | RemoveAt(Int32) | Removes a child control, at the specified index location, from the ControlCollection object. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | AsParallel() | Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.) |
![]() | AsQueryable() | Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.) |
![]() | Cast<TResult>() | Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.) |
![]() | OfType<TResult>() | Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.) |
You can access any of the properties and methods of the ControlCollection class through the Control::Controls property. Since the Control class is the base class for all ASP.NET server controls, all server controls inherit this property.
For more information about collections, see Collections and Data Structures.
The following code example overrides the Control::CreateChildControls method to create two controls, both instances of the custom class named ChildControl, which has a string property named Message. When created, the two controls are added to the ControlCollection. The Add method is called on each of these controls to add them to the class that contains this version of Control::CreateChildControls. The ChildControlsCreated property is set to true so that these controls will not be created again unnecessarily.
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



