Control.Text 속성

정의

이 컨트롤과 관련된 텍스트를 가져오거나 설정합니다.

public:
 virtual property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public virtual string Text { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Text : string with get, set
Public Overridable Property Text As String

속성 값

String

이 컨트롤과 관련된 텍스트입니다.

특성

예제

다음 코드 예제에서는 공통 속성 중 일부를 만들고 GroupBox 설정합니다. 이 예에서는 만듭니다는 TextBox 설정 및 해당 Location 그룹 상자 내에서. 그런 다음 설정의 Text 그룹 상자 및 폼의 위쪽에 도킹 된 그룹 상자는 속성입니다. 마지막으로, 그룹 상자를 설정 하 여 비활성화 된 Enabled 속성을 false, 사용 하지 않도록 설정할 그룹 상자 내에 포함 된 모든 컨트롤에 이르게 합니다.

   // Add a GroupBox to a form and set some of its common properties.
private:
   void AddMyGroupBox()
   {
      // Create a GroupBox and add a TextBox to it.
      GroupBox^ groupBox1 = gcnew GroupBox;
      TextBox^ textBox1 = gcnew TextBox;
      textBox1->Location = Point(15,15);
      groupBox1->Controls->Add( textBox1 );

      // Set the Text and Dock properties of the GroupBox.
      groupBox1->Text = "MyGroupBox";
      groupBox1->Dock = DockStyle::Top;

      // Disable the GroupBox (which disables all its child controls)
      groupBox1->Enabled = false;

      // Add the Groupbox to the form.
      this->Controls->Add( groupBox1 );
   }
// Add a GroupBox to a form and set some of its common properties.
private void AddMyGroupBox()
{
   // Create a GroupBox and add a TextBox to it.
   GroupBox groupBox1 = new GroupBox();
   TextBox textBox1 = new TextBox();
   textBox1.Location = new Point(15, 15);
   groupBox1.Controls.Add(textBox1);

   // Set the Text and Dock properties of the GroupBox.
   groupBox1.Text = "MyGroupBox";
   groupBox1.Dock = DockStyle.Top;

   // Disable the GroupBox (which disables all its child controls)
   groupBox1.Enabled = false;

   // Add the Groupbox to the form.
   this.Controls.Add(groupBox1);
}
' Add a GroupBox to a form and set some of its common properties.
Private Sub AddMyGroupBox()
   ' Create a GroupBox and add a TextBox to it.
   Dim groupBox1 As New GroupBox()
   Dim textBox1 As New TextBox()
   textBox1.Location = New Point(15, 15)
   groupBox1.Controls.Add(textBox1)
   
   ' Set the Text and Dock properties of the GroupBox.
   groupBox1.Text = "MyGroupBox"
   groupBox1.Dock = DockStyle.Top
   
   ' Disable the GroupBox (which disables all its child controls)
   groupBox1.Enabled = False
   
   ' Add the Groupbox to the form.
   Me.Controls.Add(groupBox1)
End Sub

설명

컨트롤의 속성은 Text 각 파생 클래스에서 다르게 사용됩니다. 예를 들어 합니다 Text 의 속성을 Form 폼의 맨 위에 있는 제목 표시줄에 표시 되는 문자 수가 매우 적고 이며 일반적으로 애플리케이션이 나 문서 이름이 표시 됩니다. 그러나 속성은 Text 클 수 있으며 텍스트의 RichTextBox 서식을 지정하는 데 사용되는 수많은 비전문자를 포함할 수 있습니다. 예를 들어 속성을 조정하거나 텍스트를 RichTextBox 정렬하기 Font 위해 공백이나 탭 문자를 추가하여 서식을 지정할 수 있습니다.

상속자 참고

파생 클래스의 Text 속성을 재정의할 때 기본 클래스의 Text 속성을 사용하여 기본 구현을 확장합니다. 그렇지 않으면 모든 구현을 제공해야 합니다. 속성의 set 접근자와 접근자를 모두 get 재정의할 필요는 없습니다. 필요한 경우 하나만 재정의 Text 할 수 있습니다.

적용 대상

추가 정보