Versión imprimible       Enviar     
Evaluar y enviar comentarios

  Encender vista de ancho de banda bajo
Esta página es específica de
Microsoft Visual Studio 2005/.NET Framework 2.0

Hay además otras versiones disponibles para:
TextBoxBase.Lines (Propiedad)
Obtiene o establece las líneas de texto de un control de cuadro de texto.

Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)

Visual Basic (Declaración)
<LocalizableAttribute(True)> _
Public Property Lines As String()
Visual Basic (Uso)
Dim instance As TextBoxBase
Dim value As String()

value = instance.Lines

instance.Lines = value
C#
[LocalizableAttribute(true)] 
public string[] Lines { get; set; }
C++
[LocalizableAttribute(true)] 
public:
property array<String^>^ Lines {
    array<String^>^ get ();
    void set (array<String^>^ value);
}
J#
/** @property */
public String[] get_Lines ()

/** @property */
public void set_Lines (String[] value)
JScript
public function get Lines () : String[]

public function set Lines (value : String[])
XAML
No aplicable.

Valor de propiedad

Matriz de cadenas que contiene el texto en un control de cuadro de texto.

Cada elemento de la matriz se convierte en una línea de texto en el control de cuadro de texto. Si la propiedad Multiline del control de cuadro de texto está establecida en true y aparece un carácter de nueva línea en el texto, el texto que sigue al carácter de nueva línea se agrega a un nuevo elemento de la matriz y se muestra en una línea independiente.

NotaNota:

De forma predeterminada, la colección de líneas es una copia de sólo lectura de las líneas en TextBox. Para obtener una colección de líneas en las que se pueda escribir, utilice un código parecido al siguiente: textBox1.Lines = new string[] { "abcd" };

En el siguiente ejemplo de código se utiliza TextBox, una clase derivada, para extraer todas las cadenas de texto de un control de cuadro de texto multilínea y las muestra mediante el método Debug.WriteLine. Este ejemplo requiere que se haya creado un control TextBox, denominado textBox1, y que se haya rellenado con líneas de texto.

Visual Basic
Public Sub ViewMyTextBoxContents()
    Dim counter as Integer
    'Create a string array and store the contents of the Lines property.
    Dim tempArray() as String
    tempArray = textBox1.Lines
    
    'Loop through the array and send the contents of the array to debug window.
    For counter = 0 to tempArray.GetUpperBound(0)
        System.Diagnostics.Debug.WriteLine( tempArray(counter) )
    Next
 End Sub
 
C#
public void ViewMyTextBoxContents()
 {
    // Create a string array and store the contents of the Lines property.
    string[] tempArray = textBox1.Lines;
 
    // Loop through the array and send the contents of the array to debug window.
    for(int counter=0; counter < tempArray.Length;counter++)
    {
       System.Diagnostics.Debug.WriteLine(tempArray[counter]);
    }
 }
 
C++
public:
   void ViewMyTextBoxContents()
   {
      #if defined(DEBUG)
      // Create a string array and store the contents of the Lines property.
      array<String^>^ tempArray = gcnew array<String^>( textBox1->Lines->Length );
      tempArray = textBox1->Lines;
      
      // Loop through the array and send the contents of the array to debug window.
      for ( int counter = 0; counter < tempArray->Length; counter++ )
      {
         System::Diagnostics::Debug::WriteLine( tempArray[ counter ] );
      }
      #endif
   }
J#
public void ViewMyTextBoxContents()
{
    // Create a string array and store the contents of the Lines property.
    String tempArray[] = new String[textBox1.get_Lines().length];
    tempArray = textBox1.get_Lines();
    // Loop through the array and send the contents of the array to
    // debug window.
    for (int counter = 0; counter <= tempArray.length; counter++) {
        System.Diagnostics.Debug.WriteLine(tempArray.get_Item(counter));
    }
} //ViewMyTextBoxContents

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0
© 2009 Microsoft Corporation. Reservados todos los derechos. Términos de uso  |  Marcas Registradas  |  Privacidad
Page view tracker