다음을 통해 공유


TextBoxBase.Text 속성

텍스트 상자에서 현재 텍스트를 가져오거나 설정합니다.

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

구문

‘선언
<LocalizableAttribute(True)> _
Public Overrides Property Text As String
‘사용 방법
Dim instance As TextBoxBase
Dim value As String

value = instance.Text

instance.Text = value
[LocalizableAttribute(true)] 
public override string Text { get; set; }
[LocalizableAttribute(true)] 
public:
virtual property String^ Text {
    String^ get () override;
    void set (String^ value) override;
}
/** @property */
public String get_Text ()

/** @property */
public void set_Text (String value)
public override function get Text () : String

public override function set Text (value : String)

속성 값

컨트롤에 표시된 텍스트입니다.

설명

텍스트 상자에 여러 줄의 텍스트를 표시하려면 Multiline 속성을 true로 설정합니다. 여러 줄을 입력할 수 있는 텍스트 상자의 텍스트를 읽거나 설정하려면 Lines 속성을 사용합니다. RichTextBox 컨트롤에 입력할 수 있는 텍스트의 크기는 사용하는 시스템 메모리에 의해서만 제한됩니다.

Windows 98, Windows Millennium Edition 플랫폼 참고: TextBox 컨트롤에 대해 Text 속성에 저장할 수 있는 텍스트의 크기는 65KB의 메모리로 제한됩니다.

Windows NT 4.0, Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 플랫폼 참고: Text 속성에 저장할 수 있는 텍스트의 크기는 사용 가능한 시스템 메모리 크기로 제한됩니다.

예제

다음 코드 예제에서는 파생 클래스인 TextBox를 사용하여 세로 스크롤 막대가 있고 여러 줄을 입력할 수 있는 TextBox 컨트롤을 만듭니다. 또한 이 예제에서는 AcceptsTab, AcceptsReturnWordWrap 속성을 사용하여 여러 줄을 입력할 수 있는 TextBox 컨트롤을 통해 텍스트 문서를 쉽게 만듭니다.

Public Sub CreateMyMultilineTextBox()
    ' Create an instance of a TextBox control.
    Dim textBox1 As New TextBox()
    
    ' Set the Multiline property to true.
    textBox1.Multiline = True
    ' Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical
    ' Allow the RETURN key in the TextBox control.
    textBox1.AcceptsReturn = True
    ' Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = True
    ' Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = True
    ' Set the default text of the control.
    textBox1.Text = "Welcome!" & Environment.NewLine & "Second Line"
End Sub
public void CreateMyMultilineTextBox()
 {
    // Create an instance of a TextBox control.
    TextBox textBox1 = new TextBox();
    
    // Set the Multiline property to true.
    textBox1.Multiline = true;
    // Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical;
    // Allow the RETURN key in the TextBox control.
    textBox1.AcceptsReturn = true;
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = true;
    // Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = true;
    // Set the default text of the control.
    textBox1.Text = "Welcome!" + Environment.NewLine + "Second Line";
 }
public:
   void CreateMyMultilineTextBox()
   {
      // Create an instance of a TextBox control.
      TextBox^ textBox1 = gcnew TextBox;
      
      // Set the Multiline property to true.
      textBox1->Multiline = true;
      // Add vertical scroll bars to the TextBox control.
      textBox1->ScrollBars = ScrollBars::Vertical;
      // Allow the RETURN key in the TextBox control.
      textBox1->AcceptsReturn = true;
      // Allow the TAB key to be entered in the TextBox control.
      textBox1->AcceptsTab = true;
      // Set WordWrap to true to allow text to wrap to the next line.
      textBox1->WordWrap = true;
      // Set the default text of the control.
      textBox1->Text = "Welcome!" + Environment::NewLine + "Second Line";
   }
public void CreateMyMultilineTextBox()
{
    // Create an instance of a TextBox control.
    TextBox textBox1 = new TextBox();
    // Set the Multiline property to true.
    textBox1.set_Multiline(true);
    // Add vertical scroll bars to the TextBox control.
    textBox1.set_ScrollBars(ScrollBars.Vertical);
    // Allow the RETURN key in the TextBox control.
    textBox1.set_AcceptsReturn(true);
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.set_AcceptsTab(true);
    // Set WordWrap to true to allow text to wrap to the next line.
    textBox1.set_WordWrap(true);
    // Set the default text of the control.
    textBox1.set_Text("Welcome!" + Environment.get_NewLine()
        + "Second Line");
} //CreateMyMultilineTextBox

플랫폼

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에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

TextBoxBase 클래스
TextBoxBase 멤버
System.Windows.Forms 네임스페이스
TextBoxBase.Lines 속성
TextBoxBase.Multiline 속성