ToolStripControlHost Konstruktorer
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Initierar en ny instans av ToolStripControlHost klassen.
Överlagringar
| Name | Description |
|---|---|
| ToolStripControlHost(Control) |
Initierar en ny instans av ToolStripControlHost klassen som är värd för den angivna kontrollen. |
| ToolStripControlHost(Control, String) |
Initierar en ny instans av ToolStripControlHost klassen som är värd för den angivna kontrollen och som har det angivna namnet. |
ToolStripControlHost(Control)
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
Initierar en ny instans av ToolStripControlHost klassen som är värd för den angivna kontrollen.
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)
Parametrar
- c
- Control
Den Control som hanteras av den här ToolStripControlHost klassen.
Undantag
Kontrollen som anges av parametern c är null.
Exempel
Följande kodexempel visar hur du skapar en ToolStripControlHost kontroll och anger flera egenskaper. Om du vill köra det här exemplet klistrar du in koden i ett formulär som innehåller ett ToolStrip namngivet toolStrip1 och anrop InitializeDateTimePickerHost från formulärets konstruktor eller Load händelsehanteraren.
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
Gäller för
ToolStripControlHost(Control, String)
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
- Källa:
- ToolStripControlHost.cs
Initierar en ny instans av ToolStripControlHost klassen som är värd för den angivna kontrollen och som har det angivna namnet.
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)
Parametrar
- c
- Control
Den Control som hanteras av den här ToolStripControlHost klassen.
- name
- String
Namnet på ToolStripControlHost.