ActivityToolboxItem.CreateComponentsCore(IDesignerHost) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
protected:
override cli::array <System::ComponentModel::IComponent ^> ^ CreateComponentsCore(System::ComponentModel::Design::IDesignerHost ^ host);
protected override System.ComponentModel.IComponent[] CreateComponentsCore (System.ComponentModel.Design.IDesignerHost host);
override this.CreateComponentsCore : System.ComponentModel.Design.IDesignerHost -> System.ComponentModel.IComponent[]
Protected Overrides Function CreateComponentsCore (host As IDesignerHost) As IComponent()
參數
- host
- IDesignerHost
用來裝載工具箱項目的 IDesignerHost。
傳回
建立的 IComponent 物件的陣列。
範例
下列範例顯示自訂活動的完整 ActivityToolboxItem 類別。 在本範例中,會覆寫 CreateComponentsCore 方法,以在 ParallelActivity 中插入 2 個自訂活動。
[Serializable]
internal sealed class CustomActivityToolboxItem : ActivityToolboxItem
{
public CustomActivityToolboxItem(Type type)
: base(type)
{
}
private CustomActivityToolboxItem(SerializationInfo info, StreamingContext context)
{
Deserialize(info, context);
}
protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost)
{
CompositeActivity parallel = new ParallelActivity();
parallel.Activities.Add(new CustomActivity());
parallel.Activities.Add(new CustomActivity());
return new IComponent[] { parallel };
}
}
<Serializable()> _
Friend Class CustomActivityToolboxItem
Inherits ActivityToolboxItem
Public Sub New(ByVal type As Type)
MyBase.new(type)
End Sub
Private Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
Deserialize(info, context)
End Sub
Protected Overrides Function CreateComponentsCore(ByVal designerHost As IDesignerHost) As IComponent()
Dim parallel As New ParallelActivity()
parallel.Activities.Add(New CustomActivity())
parallel.Activities.Add(New CustomActivity())
Return New IComponent() {parallel}
End Function
End Class
備註
CreateComponentsCore 方法會傳回元件或 ActivityToolboxItem 建立的元件。