ToolStripControlHost 생성자

정의

ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ToolStripControlHost class.

오버로드

ToolStripControlHost(Control)

지정된 컨트롤을 호스팅하는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ToolStripControlHost class that hosts the specified control.

ToolStripControlHost(Control, String)

지정된 컨트롤을 호스팅하고 지정된 이름을 갖는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ToolStripControlHost class that hosts the specified control and that has the specified name.

ToolStripControlHost(Control)

지정된 컨트롤을 호스팅하는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ToolStripControlHost class that hosts the specified control.

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입니다.The Control hosted by this ToolStripControlHost class.

예외

c 매개 변수로 참조된 컨트롤이 null인 경우The control referred to by the c parameter is null.

예제

다음 코드 예제를 생성 하는 방법을 보여 줍니다는 ToolStripControlHost 컨트롤과 몇 가지 속성을 설정 합니다.The following code example demonstrates constructing a ToolStripControlHost control and setting several properties. 이 예제를 실행 하려면 코드를 포함 하는 폼에 붙여 넣습니다를 ToolStrip 라는 toolStrip1 호출 InitializeDateTimePickerHost 폼의 생성자에서 또는 Load 이벤트 처리기입니다.To run this example, paste the code into a form that contains a ToolStrip named toolStrip1 and call InitializeDateTimePickerHost from the form's constructor or the Load event 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

ToolStripControlHost(Control, String)

지정된 컨트롤을 호스팅하고 지정된 이름을 갖는 ToolStripControlHost 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ToolStripControlHost class that hosts the specified control and that has the specified name.

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입니다.The Control hosted by this ToolStripControlHost class.

name
String

ToolStripControlHost의 이름입니다.The name of the ToolStripControlHost.

적용 대상