ToolboxItem.CreateComponentsCore Método

Definición

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

Sobrecargas

Nombre Description
CreateComponentsCore(IDesignerHost)

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

CreateComponentsCore(IDesignerHost, IDictionary)

Crea una matriz de componentes cuando se invoca el elemento del cuadro de herramientas.

CreateComponentsCore(IDesignerHost)

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

protected:
 virtual cli::array <System::ComponentModel::IComponent ^> ^ CreateComponentsCore(System::ComponentModel::Design::IDesignerHost ^ host);
protected virtual System.ComponentModel.IComponent[] CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host);
abstract member CreateComponentsCore : System.ComponentModel.Design.IDesignerHost -> System.ComponentModel.IComponent[]
override this.CreateComponentsCore : System.ComponentModel.Design.IDesignerHost -> System.ComponentModel.IComponent[]
Protected Overridable Function CreateComponentsCore (host As IDesignerHost) As IComponent()

Parámetros

host
IDesignerHost

que IDesignerHost se va a hospedar el elemento del cuadro de herramientas.

Devoluciones

Matriz de objetos creados IComponent .

Comentarios

Si host no nulles , el CreateComponentsCore método agrega los nuevos componentes al diseñador.

Notas a los desarrolladores de herederos

Puede invalidar el CreateComponentsCore(IDesignerHost) método para devolver el componente o los componentes que crea un elemento del cuadro de herramientas.

Consulte también

Se aplica a

CreateComponentsCore(IDesignerHost, IDictionary)

Crea una matriz de componentes cuando se invoca el elemento del cuadro de herramientas.

protected:
 virtual cli::array <System::ComponentModel::IComponent ^> ^ CreateComponentsCore(System::ComponentModel::Design::IDesignerHost ^ host, System::Collections::IDictionary ^ defaultValues);
protected virtual System.ComponentModel.IComponent[] CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host, System.Collections.IDictionary defaultValues);
abstract member CreateComponentsCore : System.ComponentModel.Design.IDesignerHost * System.Collections.IDictionary -> System.ComponentModel.IComponent[]
override this.CreateComponentsCore : System.ComponentModel.Design.IDesignerHost * System.Collections.IDictionary -> System.ComponentModel.IComponent[]
Protected Overridable Function CreateComponentsCore (host As IDesignerHost, defaultValues As IDictionary) As IComponent()

Parámetros

host
IDesignerHost

Host del diseñador que se va a usar al crear componentes.

defaultValues
IDictionary

Diccionario de pares nombre-valor de propiedad de valores predeterminados con los que inicializar el componente.

Devoluciones

Matriz de objetos creados IComponent .

Ejemplos

En el ejemplo de código siguiente se muestra el uso del CreateComponentsCore método en una clase derivada de ToolboxItem para una implementación de elemento de cuadro de herramientas personalizada. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la ToolboxItem clase .

protected override IComponent[] CreateComponentsCore(
    System.ComponentModel.Design.IDesignerHost host,
    System.Collections.IDictionary defaultValues)
{
    // Get the string we want to fill in the custom
    // user control.  If the user cancels out of the dialog,
    // return null or an empty array to signify that the 
    // tool creation was canceled.
    using (ToolboxItemDialog d = new())
    {
        if (d.ShowDialog() == DialogResult.OK)
        {
            string text = d.CreationText;

            IComponent[] comps =
                base.CreateComponentsCore(host, defaultValues);
            // comps will have a single component: our data type.
            ((UserControl1)comps[0]).LabelText = text;
            return comps;
        }
        else
        {
            return null;
        }
    }
}
Protected Overrides Function CreateComponentsCore( _
    ByVal host As System.ComponentModel.Design.IDesignerHost, _
    ByVal defaultValues As System.Collections.IDictionary) _
    As IComponent()
    ' Get the string we want to fill in the custom
    ' user control.  If the user cancels out of the dialog,
    ' return null or an empty array to signify that the 
    ' tool creation was canceled.
    Using d As New ToolboxItemDialog()
        If d.ShowDialog() = DialogResult.OK Then
            Dim [text] As String = d.CreationText
            Dim comps As IComponent() = _
                MyBase.CreateComponentsCore(host, defaultValues)
            ' comps will have a single component: our data type.
            CType(comps(0), UserControl1).LabelText = [text]
            Return comps
        Else
            Return Nothing
        End If
    End Using
End Function

Comentarios

Si host no nulles , el CreateComponentsCore método agrega los nuevos componentes al diseñador.

Se aplica a