ToolStripControlHost Constructors
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Initialiseert een nieuw exemplaar van de ToolStripControlHost klasse.
Overloads
| Name | Description |
|---|---|
| ToolStripControlHost(Control) |
Initialiseert een nieuw exemplaar van de ToolStripControlHost klasse die als host fungeert voor het opgegeven besturingselement. |
| ToolStripControlHost(Control, String) |
Initialiseert een nieuw exemplaar van de ToolStripControlHost klasse die als host fungeert voor het opgegeven besturingselement en met de opgegeven naam. |
ToolStripControlHost(Control)
Initialiseert een nieuw exemplaar van de ToolStripControlHost klasse die als host fungeert voor het opgegeven besturingselement.
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)
Parameters
- c
- Control
De Control host van deze ToolStripControlHost klasse.
Uitzonderingen
Het besturingselement waarnaar wordt verwezen door de c parameter is null.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u een ToolStripControlHost besturingselement maakt en verschillende eigenschappen instelt. Als u dit voorbeeld wilt uitvoeren, plakt u de code in een formulier met een ToolStrip naam toolStrip1 en aanroep InitializeDateTimePickerHost vanuit de constructor van het formulier of de Load gebeurtenis-handler.
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
Van toepassing op
ToolStripControlHost(Control, String)
Initialiseert een nieuw exemplaar van de ToolStripControlHost klasse die als host fungeert voor het opgegeven besturingselement en met de opgegeven naam.
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)
Parameters
- c
- Control
De Control host van deze ToolStripControlHost klasse.
- name
- String
De naam van de ToolStripControlHost.