ToolStripControlHost.Control 속성

정의

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

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

적용 대상