ToolStripControlHost Konstruktoren
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Initialisiert eine neue Instanz der ToolStripControlHost-Klasse.
Überlädt
| Name | Beschreibung |
|---|---|
| ToolStripControlHost(Control) |
Initialisiert eine neue Instanz der ToolStripControlHost Klasse, die das angegebene Steuerelement hostet. |
| ToolStripControlHost(Control, String) |
Initialisiert eine neue Instanz der ToolStripControlHost Klasse, die das angegebene Steuerelement hostet und den angegebenen Namen hat. |
ToolStripControlHost(Control)
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
Initialisiert eine neue Instanz der ToolStripControlHost Klasse, die das angegebene Steuerelement hostet.
public:
ToolStripControlHost(System::Windows::Forms::Control ^ c);
public ToolStripControlHost(System.Windows.Forms.Control c);
new System.Windows.Forms.ToolStripControlHost : System.Windows.Forms.Control -> System.Windows.Forms.ToolStripControlHost
Public Sub New (c As Control)
Parameter
- c
- Control
Die Control von dieser ToolStripControlHost Klasse gehostete Klasse.
Ausnahmen
Das steuerelement, auf das durch den c Parameter verwiesen wird, ist null.
Beispiele
Im folgenden Codebeispiel wird das Erstellen eines ToolStripControlHost Steuerelements und das Festlegen mehrerer Eigenschaften veranschaulicht. Zum Ausführen dieses Beispiels fügen Sie den Code in ein Formular ein, das einen ToolStrip benannten toolStrip1 und aufruf InitializeDateTimePickerHost vom Konstruktor des Formulars oder vom Load Ereignishandler enthält.
ToolStripControlHost^ dateTimePickerHost;
void InitializeDateTimePickerHost()
{
// Create a new ToolStripControlHost, passing in a control.
dateTimePickerHost = gcnew ToolStripControlHost( gcnew DateTimePicker );
// Set the font on the ToolStripControlHost, this will affect the hosted control.
dateTimePickerHost->Font =
gcnew System::Drawing::Font( L"Arial",7.0F,FontStyle::Italic );
// Set the Width property, this will also affect the hosted control.
dateTimePickerHost->Width = 100;
dateTimePickerHost->DisplayStyle = ToolStripItemDisplayStyle::Text;
// Setting the Text property requires a string that converts to a
// DateTime type since that is what the hosted control requires.
dateTimePickerHost->Text = L"12/23/2005";
// Cast the Control property back to the original type to set a
// type-specific property.
(dynamic_cast<DateTimePicker^>(dateTimePickerHost->Control))->Format =
DateTimePickerFormat::Short;
// Add the control host to the ToolStrip.
toolStrip1->Items->Add( dateTimePickerHost );
}
ToolStripControlHost dateTimePickerHost;
private void InitializeDateTimePickerHost()
{
// Create a new ToolStripControlHost, passing in a control.
dateTimePickerHost = new ToolStripControlHost(new DateTimePicker());
// Set the font on the ToolStripControlHost, this will affect the hosted control.
dateTimePickerHost.Font = new Font("Arial", 7.0F, FontStyle.Italic);
// Set the Width property, this will also affect the hosted control.
dateTimePickerHost.Width = 100;
dateTimePickerHost.DisplayStyle = ToolStripItemDisplayStyle.Text;
// Setting the Text property requires a string that converts to a
// DateTime type since that is what the hosted control requires.
dateTimePickerHost.Text = "12/23/2005";
// Cast the Control property back to the original type to set a
// type-specific property.
((DateTimePicker)dateTimePickerHost.Control).Format = DateTimePickerFormat.Short;
// Add the control host to the ToolStrip.
toolStrip1.Items.Add(dateTimePickerHost);
}
Private dateTimePickerHost As ToolStripControlHost
Private Sub InitializeDateTimePickerHost()
' Create a new ToolStripControlHost, passing in a control.
dateTimePickerHost = New ToolStripControlHost(New DateTimePicker())
' Set the font on the ToolStripControlHost, this will affect the hosted control.
dateTimePickerHost.Font = New Font("Arial", 7.0F, FontStyle.Italic)
' Set the Width property, this will also affect the hosted control.
dateTimePickerHost.Width = 100
dateTimePickerHost.DisplayStyle = ToolStripItemDisplayStyle.Text
' Setting the Text property requires a string that converts to a
' DateTime type since that is what the hosted control requires.
dateTimePickerHost.Text = "12/23/2005"
' Cast the Control property back to the original type to set a
' type-specific property.
CType(dateTimePickerHost.Control, DateTimePicker).Format = DateTimePickerFormat.Short
' Add the control host to the ToolStrip.
toolStrip1.Items.Add(dateTimePickerHost)
End Sub
Gilt für:
ToolStripControlHost(Control, String)
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
- Quelle:
- ToolStripControlHost.cs
Initialisiert eine neue Instanz der ToolStripControlHost Klasse, die das angegebene Steuerelement hostet und den angegebenen Namen hat.
public:
ToolStripControlHost(System::Windows::Forms::Control ^ c, System::String ^ name);
public ToolStripControlHost(System.Windows.Forms.Control c, string name);
new System.Windows.Forms.ToolStripControlHost : System.Windows.Forms.Control * string -> System.Windows.Forms.ToolStripControlHost
Public Sub New (c As Control, name As String)
Parameter
- c
- Control
Die Control von dieser ToolStripControlHost Klasse gehostete Klasse.
- name
- String
Der Name des ToolStripControlHost.