다음을 통해 공유


TextBoxBase.Lines 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<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[])

속성 값

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

설명

해당 배열의 각 요소는 TextBox 컨트롤의 텍스트 줄이 됩니다. TextBox 컨트롤의 Multiline 속성이 true로 설정되어 있고 텍스트에 줄 바꿈 문자가 있으면 줄 바꿈 문자 다음의 텍스트는 배열의 새 요소에 추가되고 별도의 줄에 표시됩니다.

참고

기본적으로 줄의 컬렉션은 TextBox에 포함된 줄의 읽기 전용 복사본입니다. 쓰기 가능한 줄 컬렉션을 가져오려면 textBox1.Lines = new string[] { "abcd" };과 비슷한 코드를 사용합니다.

예제

다음 코드 예제에서는 파생 클래스인 TextBox를 사용하여 여러 줄을 입력할 수 있는 TextBox 컨트롤에서 모든 텍스트 문자열을 추출하고 Debug.WriteLine 메서드를 사용하여 해당 문자열을 표시합니다. 또한 이 예제에서는 textBox1이라는 TextBox 컨트롤이 만들어져 있고 이 컨트롤이 텍스트 줄로 채워져 있어야 합니다.

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

플랫폼

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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

TextBoxBase 클래스
TextBoxBase 멤버
System.Windows.Forms 네임스페이스
Text