RichTextBox.SelectionCharOffset 속성

정의

컨트롤의 텍스트가 기준선 위에 위 첨자로 표시되거나 기준선 아래에 아래 첨자로 표시되는지 여부를 가져오거나 설정합니다.

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

속성 값

Int32

문자 오프셋을 지정하는 숫자입니다.

특성

예외

지정된 값이 -2000보다 작거나 2000보다 큰 경우

예제

다음 코드 예제에서는 사용 속성 내에서 RichTextBox SelectionCharOffset 위 첨자 및 아래 첨자 텍스트를 지정 하는 방법을 보여 줍니다. 이 예제에서는 명명richTextBox1RichTextBox 컨트롤이 양식에 추가되어야 합니다.

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

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

      // Set the foreground color of the text.
      richTextBox1->SelectionColor = Color::Purple;

      // Set the baseline text.
      richTextBox1->SelectedText = "10";

      // Set the CharOffset to display superscript text.
      richTextBox1->SelectionCharOffset = 10;

      // Set the superscripted text. 
      richTextBox1->SelectedText = "2";

      // Reset the CharOffset to display text at the baseline.
      richTextBox1->SelectionCharOffset = 0;
      richTextBox1->AppendText( "\n\n" );

      // Change the forecolor of the next text selection.
      richTextBox1->SelectionColor = Color::Blue;

      // Set the baseline text.
      richTextBox1->SelectedText = "77";

      // Set the CharOffset to display subscript text.
      richTextBox1->SelectionCharOffset = -10;

      // Set the subscripted text.  
      richTextBox1->SelectedText = "3";

      // Reset the CharOffset to display text at the baseline.
      richTextBox1->SelectionCharOffset = 0;
   }
private void WriteOffsetTextToRichTextBox()
{
    // Clear all text from the RichTextBox.
    richTextBox1.Clear();
    // Set the font for the text.
    richTextBox1.SelectionFont = new Font("Lucinda Console", 12);
    // Set the foreground color of the text.
    richTextBox1.SelectionColor = Color.Purple;
    // Set the baseline text.
    richTextBox1.SelectedText = "10";
    // Set the CharOffset to display superscript text.
    richTextBox1.SelectionCharOffset = 10;
    // Set the superscripted text.	
    richTextBox1.SelectedText = "2";
    // Reset the CharOffset to display text at the baseline.
    richTextBox1.SelectionCharOffset = 0;
    richTextBox1.AppendText("\n\n");
    // Change the forecolor of the next text selection.
    richTextBox1.SelectionColor = Color.Blue;
    // Set the baseline text.
    richTextBox1.SelectedText = "77";
    // Set the CharOffset to display subscript text.
    richTextBox1.SelectionCharOffset = -10;
    // Set the subscripted text.  
    richTextBox1.SelectedText = "3";
    // Reset the CharOffset to display text at the baseline.
    richTextBox1.SelectionCharOffset = 0; 
}
Private Sub WriteOffsetTextToRichTextBox()
   ' Clear all text from the RichTextBox.
   RichTextBox1.Clear()
   ' Set the font for the text.
   RichTextBox1.SelectionFont = New Font("Lucinda Console", 12)
   ' Set the foreground color of the text.
   RichTextBox1.SelectionColor = Color.Purple
   ' Set the baseline text.
   RichTextBox1.SelectedText = "10"
   ' Set the CharOffset to display superscript text.
   RichTextBox1.SelectionCharOffset = 10
   ' Set the superscripted text.	
   RichTextBox1.SelectedText = "2"
   ' Reset the CharOffset to display text at the baseline.
   RichTextBox1.SelectionCharOffset = 0
   RichTextBox1.SelectedText = ControlChars.CrLf + ControlChars.CrLf
   ' Change the forecolor of the next text selection.
   RichTextBox1.SelectionColor = Color.Blue
   ' Set the baseline text.
   RichTextBox1.SelectedText = "777"
   ' Set the CharOffset to display subscript text.
   RichTextBox1.SelectionCharOffset = -10
   ' Set the subscripted text.  
   RichTextBox1.SelectedText = "3"
   ' Reset the CharOffset to display text at the baseline.
   RichTextBox1.SelectionCharOffset = 0
End Sub

설명

이 속성의 값은 -2000에서 2000 사이여야 합니다.

이 속성을 0으로 설정하면 텍스트가 기준선에 나타납니다. 양수인 경우 이 숫자는 텍스트 선택 영역을 기준선 위로 올릴 픽셀 수를 지정합니다. 음수인 경우 이 숫자는 텍스트 선택을 첨자할 픽셀 수를 지정합니다. 이 속성을 사용하여 텍스트를 위 첨자 또는 아래 첨자로 지정할 수 있습니다.

텍스트를 선택하지 않으면 현재 삽입 지점과 사용자가 삽입 지점 뒤에 입력하는 모든 텍스트에 오프셋이 적용됩니다. 문자 오프셋은 속성이 다른 값으로 변경되거나 삽입 포인터가 컨트롤 내의 다른 섹션으로 이동할 때까지 적용됩니다.

컨트롤 내에서 텍스트를 선택하면 선택한 텍스트와 텍스트 선택 후 입력된 모든 텍스트에 이 속성의 값이 적용됩니다. 수치 연산 식으로 이러한 애플리케이션에 대 한 첨자 및 아래 첨자 텍스트를 만들려면이 속성을 사용할 수 있습니다.

적용 대상