RichTextBox.SelectionAlignment 속성

정의

현재 선택 영역 또는 삽입 지점에 적용할 맞춤 방식을 가져오거나 설정합니다.

public:
 property System::Windows::Forms::HorizontalAlignment SelectionAlignment { System::Windows::Forms::HorizontalAlignment get(); void set(System::Windows::Forms::HorizontalAlignment value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.HorizontalAlignment SelectionAlignment { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionAlignment : System.Windows.Forms.HorizontalAlignment with get, set
Public Property SelectionAlignment As HorizontalAlignment

속성 값

HorizontalAlignment

HorizontalAlignment 값 중 하나입니다.

특성

예외

지정된 값이 HorizontalAlignment 클래스에 정의된 값 중 하나가 아닌 경우

예제

다음 코드 예제에서는 내에서 텍스트를 정렬하는 방법을 보여 줍니다 RichTextBox. 이 예제에서는 명명richTextBox1RichTextBox 컨트롤이 양식에 추가되어야 합니다.

private:
   void WriteCenteredTextToRichTextBox()
   {
      // Clear all text from the RichTextBox;
      richTextBox1->Clear();

      // Set the foreground color of the text.
      richTextBox1->ForeColor = Color::Red;

      // Set the alignment of the text that follows.
      richTextBox1->SelectionAlignment = HorizontalAlignment::Center;

      // Set the font for the text.
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Lucinda Console",12 );

      // Set the text within the control.
      richTextBox1->SelectedText = "This text is centered using the SelectionAlignment property.\n";
   }
private void WriteCenteredTextToRichTextBox()
{
   // Clear all text from the RichTextBox;
   richTextBox1.Clear();
   // Set the foreground color of the text.
   richTextBox1.ForeColor = Color.Red;
   // Set the alignment of the text that follows.
   richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
   // Set the font for the text.
   richTextBox1.SelectionFont = new Font("Lucinda Console", 12);
   // Set the text within the control.
   richTextBox1.SelectedText = "This text is centered using the SelectionAlignment property.\n";
}
Private Sub WriteCenteredTextToRichTextBox()
   ' Clear all text from the RichTextBox;
   richTextBox1.Clear()
   ' Set the foreground color of the text.
   richTextBox1.SelectionColor = Color.Red
   ' Set the alignment of the text that follows.
   richTextBox1.SelectionAlignment = HorizontalAlignment.Center
   ' Set the font for the text.
   richTextBox1.SelectionFont = new Font("Lucinda Console", 12)
   ' Set the text within the control.
   richTextBox1.SelectedText = "This text is centered using the SelectionAlignment property."

End Sub

설명

컨트롤에서 단락을 선택하지 않은 경우 이 속성을 설정하면 맞춤 속성 설정이 있는 단락 뒤에 만든 단락뿐만 아니라 삽입 포인터가 나타나는 단락에도 맞춤 설정이 적용됩니다. 예를 들어 컨트롤에 RichTextBox 두 개의 단락이 있고 삽입 포인터가 두 번째 단락 내에 있는 경우입니다. 속성을 HorizontalAlignment.Center설정 SelectionAlignment 하면 삽입 지점의 단락이 컨트롤의 가운데에 배치됩니다. 두 번째 단락 뒤에 세 번째 단락이 만들어지면 컨트롤의 가운데에도 맞춰집니다.

속성을 설정할 때 컨트롤 내에서 선택한 경우 선택한 모든 단락이 이 속성 설정에 따라 정렬됩니다. 이 속성을 사용하여 문서에서 만들고 있는 문서의 단락을 정렬할 수 있습니다 RichTextBox. 예를 들어 문서의 모든 단락을 가운데에 배치하려면 컨트롤의 모든 단락을 선택하고 속성을 으로 HorizontalAlignment.Center설정할 SelectionAlignment 수 있습니다.

참고

SelectionAlignment 는 텍스트 선택 영역에 맞춤이 혼합된 여러 단락이 포함된 경우를 반환 SelectionAlignment.Left 합니다.

적용 대상

추가 정보