Bagikan melalui


ToolboxItem.CreateComponentsCore Metode

Definisi

Membuat komponen atau array komponen saat item kotak alat dipanggil.

Overload

CreateComponentsCore(IDesignerHost)

Membuat komponen atau array komponen saat item kotak alat dipanggil.

CreateComponentsCore(IDesignerHost, IDictionary)

Membuat array komponen saat item kotak alat dipanggil.

CreateComponentsCore(IDesignerHost)

Membuat komponen atau array komponen saat item kotak alat dipanggil.

protected:
 virtual cli::array <System::ComponentModel::IComponent ^> ^ CreateComponentsCore(System::ComponentModel::Design::IDesignerHost ^ host);
protected virtual 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()

Parameter

host
IDesignerHost

IDesignerHost untuk menghosting item kotak alat.

Mengembalikan

Array objek yang dibuat IComponent .

Keterangan

Jika host tidak null, CreateComponentsCore metode menambahkan komponen baru ke perancang.

Catatan Bagi Inheritor

Anda dapat mengambil alih CreateComponentsCore(IDesignerHost) metode untuk mengembalikan komponen atau komponen yang dibuat item kotak alat.

Lihat juga

Berlaku untuk

CreateComponentsCore(IDesignerHost, IDictionary)

Membuat array komponen saat item kotak alat dipanggil.

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

Parameter

host
IDesignerHost

Host perancang untuk digunakan saat membuat komponen.

defaultValues
IDictionary

Kamus nama properti/pasangan nilai nilai nilai default untuk menginisialisasi komponen.

Mengembalikan

Array objek yang dibuat IComponent .

Contoh

Contoh kode berikut menunjukkan penggunaan CreateComponentsCore metode di kelas yang berasal dari ToolboxItem untuk implementasi item kotak alat kustom. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk ToolboxItem kelas .

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

Keterangan

Jika host tidak null, CreateComponentsCore metode menambahkan komponen baru ke perancang.

Berlaku untuk