IDesignerHost.CreateComponent Method

Definition

Creates a component of the specified type and adds it to the design document.

Overloads

CreateComponent(Type)

Creates a component of the specified type and adds it to the design document.

CreateComponent(Type, String)

Creates a component of the specified type and name, and adds it to the design document.

CreateComponent(Type)

Creates a component of the specified type and adds it to the design document.

C#
public System.ComponentModel.IComponent CreateComponent(Type componentClass);

Parameters

componentClass
Type

The type of the component to create.

Returns

The newly created component.

Remarks

If the type cannot be resolved into an object that implements IComponent, an exception is thrown.

This method does not specify a name for the component. The method creates the component and adds it to the designer container.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

CreateComponent(Type, String)

Creates a component of the specified type and name, and adds it to the design document.

C#
public System.ComponentModel.IComponent CreateComponent(Type componentClass, string name);

Parameters

componentClass
Type

The type of the component to create.

name
String

The name for the component.

Returns

The newly created component.

Remarks

If the type cannot be resolved into an object that implements IComponent, an exception is thrown.

This method creates the component and adds it to the designer container.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1