다음을 통해 공유


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

속성 값

이 컨트롤과 연결된 텍스트입니다.

특성

예제

다음 코드 예제에서는 공통 속성 중 일부를 만들고 GroupBox 설정합니다. 이 예제에서는 그룹 상자 내에서 a TextBox 를 만들고 설정합니다 Location . 다음으로 그룹 상자의 속성을 설정하고 Text 그룹 상자를 폼의 맨 위에 도킹합니다. 마지막으로 그룹 상자에 포함된 모든 컨트롤을 사용하지 않도록 설정하는 속성을 false설정하여 그룹 상자를 사용하지 않도록 설정합니다Enabled.

   // 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 서식을 지정하는 데 사용되는 수많은 비전문자를 포함할 수 있습니다. 예를 들어 속성을 조정 Font 하거나 공백이나 탭 문자를 추가하여 텍스트를 RichTextBox 정렬하여 서식을 지정할 수 있습니다.

상속자 참고

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

적용 대상

추가 정보