TextBoxBase.Lines Özellik

Tanım

Metin kutusu denetimindeki metin satırlarını alır veya ayarlar.

public:
 property cli::array <System::String ^> ^ Lines { cli::array <System::String ^> ^ get(); void set(cli::array <System::String ^> ^ value); };
public string[] Lines { get; set; }
member this.Lines : string[] with get, set
Public Property Lines As String()

Özellik Değeri

String[]

Metin kutusu denetimindeki metni içeren dize dizisi.

Örnekler

Aşağıdaki kod örneği, çok satırlı bir metin kutusu denetiminden tüm metin dizelerini ayıklamak ve yöntemini kullanarak Debug.WriteLine bunları görüntülemek için türetilmiş bir sınıf kullanırTextBox. Bu örnek, adlı textBox1bir TextBox denetimin oluşturulmasını ve metin satırlarıyla doldurulduğunu gerektirir.

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 = 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 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

Açıklamalar

Dizideki her öğe, metin kutusu denetiminde bir metin satırı olur. Multiline Metin kutusu denetiminin özelliği olarak true ayarlanırsa ve metinde yeni satır karakteri görüntülenirse, yeni satır karakterini izleyen metin dizideki yeni bir öğeye eklenir ve ayrı bir satırda görüntülenir.

Not

Varsayılan olarak, satır koleksiyonu içindeki satırların TextBoxsalt okunur bir kopyasıdır. Yazılabilir bir satır koleksiyonu almak için aşağıdakine benzer bir kod kullanın: textBox1.Lines = new string[] { "abcd" };

Şunlara uygulanır

Ayrıca bkz.