IDesignerHost.CreateComponent 方法

定義

建立指定型別的元件,並將其加入至設計文件中。

多載

CreateComponent(Type)

建立指定型別的元件,並將其加入至設計文件中。

CreateComponent(Type, String)

建立指定型別和名稱的元件,並將其加入至設計文件中。

CreateComponent(Type)

建立指定型別的元件,並將其加入至設計文件中。

public:
 System::ComponentModel::IComponent ^ CreateComponent(Type ^ componentClass);
public System.ComponentModel.IComponent CreateComponent (Type componentClass);
abstract member CreateComponent : Type -> System.ComponentModel.IComponent
Public Function CreateComponent (componentClass As Type) As IComponent

參數

componentClass
Type

要建立的元件類型。

傳回

新建立的元件。

備註

如果類型無法解析為實作 IComponent的物件,則會擲回例外狀況。

這個方法不會指定元件的名稱。 方法會建立元件,並將其新增至設計工具容器。

另請參閱

適用於

CreateComponent(Type, String)

建立指定型別和名稱的元件,並將其加入至設計文件中。

public:
 System::ComponentModel::IComponent ^ CreateComponent(Type ^ componentClass, System::String ^ name);
public System.ComponentModel.IComponent CreateComponent (Type componentClass, string name);
abstract member CreateComponent : Type * string -> System.ComponentModel.IComponent
Public Function CreateComponent (componentClass As Type, name As String) As IComponent

參數

componentClass
Type

要建立的元件類型。

name
String

元件的名稱。

傳回

新建立的元件。

備註

如果類型無法解析為實作 IComponent的物件,則會擲回例外狀況。

這個方法會建立元件,並將其新增至設計工具容器。

另請參閱

適用於