ToolboxItem.CreateComponentsCore Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Crée un composant ou un tableau de composants lorsque l’élément de boîte à outils est appelé.
Surcharges
| Nom | Description |
|---|---|
| CreateComponentsCore(IDesignerHost) |
Crée un composant ou un tableau de composants lorsque l’élément de boîte à outils est appelé. |
| CreateComponentsCore(IDesignerHost, IDictionary) |
Crée un tableau de composants lorsque l’élément de boîte à outils est appelé. |
CreateComponentsCore(IDesignerHost)
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
Crée un composant ou un tableau de composants lorsque l’élément de boîte à outils est appelé.
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()
Paramètres
- host
- IDesignerHost
Pour IDesignerHost héberger l’élément de boîte à outils.
Retours
Tableau d’objets créés IComponent .
Remarques
Si host ce n’est pas nullle cas, la CreateComponentsCore méthode ajoute les nouveaux composants au concepteur.
Notes pour les héritiers
Vous pouvez remplacer la CreateComponentsCore(IDesignerHost) méthode pour renvoyer le composant ou les composants créés par un élément de boîte à outils.
Voir aussi
S’applique à
CreateComponentsCore(IDesignerHost, IDictionary)
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
- Source:
- ToolboxItem.cs
Crée un tableau de composants lorsque l’élément de boîte à outils est appelé.
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()
Paramètres
- host
- IDesignerHost
Hôte du concepteur à utiliser lors de la création de composants.
- defaultValues
- IDictionary
Dictionnaire de paires nom/valeur de propriété de valeurs par défaut avec lesquelles initialiser le composant.
Retours
Tableau d’objets créés IComponent .
Exemples
L’exemple de code suivant illustre l’utilisation de la CreateComponentsCore méthode dans une classe dérivée d’une ToolboxItem implémentation d’élément de boîte à outils personnalisée. Cet exemple de code fait partie d’un exemple plus grand fourni pour la ToolboxItem classe.
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
Remarques
Si host ce n’est pas nullle cas, la CreateComponentsCore méthode ajoute les nouveaux composants au concepteur.