ToolStripControlHost.Control プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
この Control がホストしている ToolStripControlHost を取得します。
public:
property System::Windows::Forms::Control ^ Control { System::Windows::Forms::Control ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Control Control { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Control : System.Windows.Forms.Control
Public ReadOnly Property Control As Control
プロパティ値
この Control がホストしている ToolStripControlHost。
- 属性
例
次のコード例は、コントロールを構築し、そのプロパティを ToolStripControlHost 使用してラップされたコントロールにプロパティを設定する方法を Control 示しています。 この例を実行するには、フォームのコンストラクターまたはイベント ハンドラーからの名前付きtoolStrip1
呼び出InitializeDateTimePickerHost
しを含むToolStripフォームにコードをLoad
貼り付けます。
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