RichTextBox.SelectionCharOffset 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컨트롤의 텍스트가 기준선, 위 첨자 또는 기준선 아래의 아래 첨자로 표시되는지 여부를 가져오거나 설정합니다.
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
속성 값
문자 오프셋을 지정하는 숫자입니다.
- 특성
예외
지정한 값이 -2000 미만이거나 2000보다 큰 경우
예제
다음 코드 예제에서는 using 속성 내에서 위 첨자 및 아래 첨자 텍스트를 지정하는 RichTextBoxSelectionCharOffset 방법을 보여 줍니다. 이 예제에서는 RichTextBox 이름이 지정된 richTextBox1컨트롤이 양식에 추가되어야 합니다.
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으로 설정하면 텍스트가 기준선에 나타납니다. 양수인 경우 이 숫자는 텍스트 선택 영역을 기준선 위로 올릴 픽셀 수를 지정합니다. 음수인 경우 이 숫자는 텍스트 선택 영역을 첨자할 픽셀 수를 지정합니다. 이 속성을 사용하여 텍스트를 위 첨자 또는 아래 첨자로 지정할 수 있습니다.
텍스트를 선택하지 않으면 현재 삽입 지점과 사용자가 삽입 지점 뒤에 입력하는 모든 텍스트에 오프셋이 적용됩니다. 문자 오프셋은 속성이 다른 값으로 변경되거나 삽입 지점이 컨트롤 내의 다른 섹션으로 이동할 때까지 적용됩니다.
컨트롤 내에서 텍스트를 선택하면 선택한 텍스트와 텍스트 선택 뒤에 입력된 모든 텍스트에 이 속성의 값이 적용됩니다. 수학적 식과 같은 애플리케이션에 대한 위 첨자 및 아래 첨자 텍스트를 만들려면 이 속성을 사용할 수 있습니다.