Freigeben über


TextBoxBase.Lines-Eigenschaft

Ruft die Textzeilen in einem Textfeld-Steuerelement ab oder legt diese fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<LocalizableAttribute(True)> _
Public Property Lines As String()
'Usage
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[])

Eigenschaftenwert

Ein Array mit Zeichenfolgen, das den Text in einem Textfeld-Steuerelement enthält.

Hinweise

Jedem Element im Array wird eine Textzeile im Textfeld-Steuerelement zugeordnet. Wenn die Multiline-Eigenschaft des Textfeld-Steuerelements auf true festgelegt ist und der Text ein Zeilenumbruchzeichen enthält, wird der nachfolgende Text einem neuen Element im Array zugeordnet und in einer eigenen Zeile angezeigt.

Hinweis

Standardmäßig ist die Auflistung der Zeilen eine schreibgeschützte Kopie der Zeilen in TextBox. Um eine Auflistung der Zeilen abzurufen, die nicht schreibgeschützt ist, verwenden Sie Code der folgenden Form: textBox1.Lines = new string[] { "abcd" };

Beispiel

Im folgenden Codebeispiel werden mithilfe der abgeleiteten Klasse TextBox alle Textzeichenfolgen in einem mehrzeiligen Textfeld-Steuerelement extrahiert und mit der Debug.WriteLine-Methode angezeigt. In diesem Beispiel ist es erforderlich, dass in das neu erstellte TextBox-Steuerelement textBox1 bereits Textzeilen eingefügt wurden.

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 = new 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]);
    }
 }
 
public:
   void ViewMyTextBoxContents()
   {
      // 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 ] );
      }
   }
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

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

TextBoxBase-Klasse
TextBoxBase-Member
System.Windows.Forms-Namespace
Text