Adds the specified component to the Container and assigns a name to it.
[Visual Basic] Overloads Overridable Public Sub Add( _ ByVal component As IComponent, _ ByVal name As String _ ) [C#] public virtual void Add( IComponent component, string name ); [C++] public: virtual void Add( IComponent* component, String* name ); [JScript] public function Add( component : IComponent, name : String );
-or-
a null reference (in Visual Basic Nothing) to leave the component unnamed.
None.
Exception Type | Condition |
---|---|
InvalidOperationException | name is already used by another component in the Container. |
This method can be overridden by a derived class.
The components in a container are tracked in a first-in-first-out list, which also defines the order of the components within the container. The new component is added to the end of the list.Components may or may not have a name. If a component is given a name, the name must be unique among the names of the components within the Container.
Container Class | Container Members | System.ComponentModel Namespace | Container.Add Overload List | Remove