Compartir a través de


ActivityToolboxItem.CreateComponentsCore(IDesignerHost) Método

Definición

Crea un componente Activity o una matriz de componentes Activity cuando se invoca el elemento del cuadro de herramientas.

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()

Parámetros

host
IDesignerHost

IDesignerHost que hospeda el elemento del cuadro de herramientas.

Devoluciones

Matriz de objetos IComponent creados.

Ejemplos

En el ejemplo siguiente se muestra una clase completa ActivityToolboxItem para una actividad personalizada. En este ejemplo, el método CreateComponentsCore se invalida para insertar 2 actividades personalizadas dentro de ParallelActivity.

[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

Comentarios

El método CreateComponentsCore devuelve el componente o los componentes que crea ActivityToolboxItem.

Se aplica a