TextBoxBase.AppendText(String) 메서드

정의

텍스트 상자의 현재 텍스트에 텍스트를 추가합니다.

public:
 void AppendText(System::String ^ text);
public void AppendText (string text);
public void AppendText (string? text);
member this.AppendText : string -> unit
Public Sub AppendText (text As String)

매개 변수

text
String

텍스트 상자의 현재 내용에 추가할 텍스트입니다.

예제

다음 코드 예제에서는 메서드와 TextLength 속성을 사용하여 AppendText 텍스트를 서로 TextBox 복사하는 방법을 보여 줍니다. 이 예제에서는 명명된 두 개의 TextBox 컨트롤과 textBox2폼에 추가되었으며 해당 속성에 텍스트가 textBox1 할당되어 있어야 합니다Text. textBox1

void AppendTextBox1Text()
{
   // Determine if text is selected in textBox1.
   if ( textBox1->SelectionLength == 0 )

   // No selection made, return.
   return;

   // Determine if the text being appended to textBox2 exceeds the MaxLength property.
   if ( (textBox1->SelectedText->Length + textBox2->TextLength) > textBox2->MaxLength )
         MessageBox::Show( "The text to paste in is larger than the maximum number of characters allowed" ); // Append the text from textBox1 into textBox2.
   else
         textBox2->AppendText( textBox1->SelectedText );
}
private void AppendTextBox1Text()
{
   // Determine if text is selected in textBox1.
   if(textBox1.SelectionLength == 0)
      // No selection made, return.
      return;
   
   // Determine if the text being appended to textBox2 exceeds the MaxLength property.
   if((textBox1.SelectedText.Length + textBox2.TextLength) > textBox2.MaxLength)
      MessageBox.Show("The text to paste in is larger than the maximum number of characters allowed");
   else
      // Append the text from textBox1 into textBox2.
      textBox2.AppendText(textBox1.SelectedText);
}
Private Sub AppendTextBox1Text()
   ' Determine if text is selected in textBox1.
   If textBox1.SelectionLength = 0 Then
      ' No selection made, return.
      Return
   End If
   ' Determine if the text being appended to textBox2 exceeds the MaxLength property.
   If textBox1.SelectedText.Length + textBox2.TextLength > textBox2.MaxLength Then
      MessageBox.Show("The text to paste in is larger than the maximum number of characters allowed")
      ' Append the text from textBox1 into textBox2.
   Else
      textBox2.AppendText(textBox1.SelectedText)
   End If
End Sub

설명

이 메서드를 사용 하 여 연결 연산자 (+)를 사용 하 여 속성에 텍스트를 연결 하는 대신 컨트롤의 기존 텍스트에 Text 텍스트를 추가할 수 있습니다.

적용 대상

추가 정보