TextBoxBase.Text Propiedad

Definición

Obtiene o establece el texto actual del cuadro de texto.

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

Texto que se muestra en el control.

Ejemplos

En el ejemplo de código siguiente se usa TextBox, una clase derivada, para crear un control de varias líneas TextBox con barras de desplazamiento verticales. En este ejemplo también se usan las AcceptsTabpropiedades , AcceptsReturny WordWrap para que el control de cuadro de texto de varias líneas sea útil para crear documentos de texto.

public:
   void CreateMyMultilineTextBox()
   {
      // Create an instance of a TextBox control.
      TextBox^ textBox1 = gcnew TextBox;
      
      // Set the Multiline property to true.
      textBox1->Multiline = true;
      // Add vertical scroll bars to the TextBox control.
      textBox1->ScrollBars = ScrollBars::Vertical;
      // Allow the RETURN key in the TextBox control.
      textBox1->AcceptsReturn = true;
      // Allow the TAB key to be entered in the TextBox control.
      textBox1->AcceptsTab = true;
      // Set WordWrap to true to allow text to wrap to the next line.
      textBox1->WordWrap = true;
      // Set the default text of the control.
      textBox1->Text = "Welcome!" + Environment::NewLine + "Second Line";
   }
public void CreateMyMultilineTextBox()
 {
    // Create an instance of a TextBox control.
    TextBox textBox1 = new TextBox();
    
    // Set the Multiline property to true.
    textBox1.Multiline = true;
    // Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical;
    // Allow the RETURN key in the TextBox control.
    textBox1.AcceptsReturn = true;
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = true;
    // Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = true;
    // Set the default text of the control.
    textBox1.Text = "Welcome!" + Environment.NewLine + "Second Line";
 }
Public Sub CreateMyMultilineTextBox()
    ' Create an instance of a TextBox control.
    Dim textBox1 As New TextBox()
    
    ' Set the Multiline property to true.
    textBox1.Multiline = True
    ' Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical
    ' Allow the RETURN key in the TextBox control.
    textBox1.AcceptsReturn = True
    ' Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = True
    ' Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = True
    ' Set the default text of the control.
    textBox1.Text = "Welcome!" & Environment.NewLine & "Second Line"
End Sub

Comentarios

Para mostrar varias líneas de texto en un cuadro de texto, establezca la Multiline propiedad trueen . Para leer o establecer el texto de un cuadro de texto de varias líneas, use la Lines propiedad . La cantidad de texto que se puede escribir en el RichTextBox control solo está limitada por la memoria del sistema disponible.

Se aplica a

Consulte también