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()
Dim instance As TextBoxBase
Dim value As String()
value = instance.Lines
instance.Lines = value
[LocalizableAttribute(true)]
public string[] Lines { get; set; }
[LocalizableAttribute(true)]
public:
property array<String^>^ Lines {
array<String^>^ get ();
void set (array<String^>^ value);
}
/** @property */
public String[] get_Lines ()
/** @property */
public void set_Lines (String[] value)
public function get Lines () : String[]
public function set Lines (value : String[])
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.
Nota: |
|---|
| 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.
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
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]);
}
}
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
}
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