ToolStripControlHost 생성자

정의

ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.

오버로드

ToolStripControlHost(Control)

지정된 컨트롤을 호스팅하는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.

ToolStripControlHost(Control, String)

지정된 컨트롤을 호스팅하고 지정된 이름을 갖는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.

ToolStripControlHost(Control)

지정된 컨트롤을 호스팅하는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.

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)

매개 변수

c
Control

Control 클래스에 의해 호스팅되는 ToolStripControlHost입니다.

예외

c 매개 변수로 참조된 컨트롤이 null인 경우

예제

다음 코드 예제에서는 컨트롤을 생성 하 고 ToolStripControlHost 여러 속성을 설정 하는 방법을 보여 줍니다. 이 예제를 실행하려면 형식의 생성자 또는 이벤트 처리기에서 명명 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

적용 대상

ToolStripControlHost(Control, String)

지정된 컨트롤을 호스팅하고 지정된 이름을 갖는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.

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)

매개 변수

c
Control

Control 클래스에 의해 호스팅되는 ToolStripControlHost입니다.

name
String

ToolStripControlHost의 이름입니다.

적용 대상