ToolStripControlHost.Text ToolStripControlHost.Text ToolStripControlHost.Text ToolStripControlHost.Text Property

Definición

Obtiene o establece el texto que se va a mostrar en el control hospedado.Gets or sets the text to be displayed on the hosted control.

public:
 virtual property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public override string Text { get; set; }
member this.Text : string with get, set
Public Overrides Property Text As String

Valor de propiedad

Un objeto String que representa el texto.A String representing the text.

Ejemplos

En el ejemplo de código siguiente se muestra ToolStripControlHost cómo crear un control y establecer varias propiedades.The following code example demonstrates constructing a ToolStripControlHost control and setting several properties. Para ejecutar este ejemplo, pegue el código en un formulario que contenga ToolStrip un toolStrip1 denominado y InitializeDateTimePickerHost llame a desde el constructor del formulario Load o el controlador de eventos.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

Se aplica a