TextBoxBase.Lines 속성

정의

TextBox 컨트롤의 텍스트 줄을 가져오거나 설정합니다.

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()

속성 값

String[]

TextBox 컨트롤의 텍스트가 들어 있는 문자열 배열입니다.

예제

다음 코드 예제에서는 파생 클래스를 사용하여 TextBox여러 줄 텍스트 상자 컨트롤에서 텍스트의 모든 문자열을 추출하고 메서드를 사용하여 Debug.WriteLine 표시합니다. 이 예제에서는 컨트롤을 TextBox 만들고, 명명 textBox1하고, 텍스트 줄로 채워야 합니다.

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

설명

배열의 각 요소는 텍스트 상자 컨트롤의 텍스트 줄이 됩니다. Multiline 텍스트 상자 컨트롤의 속성을 설정하고 true 텍스트에 줄 바꿈 문자가 나타나면 줄 바꿈 문자 다음에 나오는 텍스트가 배열의 새 요소에 추가되고 별도의 줄에 표시됩니다.

참고

기본적으로 줄 컬렉션은 에 있는 TextBox줄의 읽기 전용 복사본입니다. 쓰기 가능한 줄 컬렉션을 얻으려면 다음과 유사한 코드를 사용합니다. textBox1.Lines = new string[] { "abcd" };

적용 대상

추가 정보