RichTextBox.SelectionCharOffset プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As RichTextBox Dim value As Integer value = instance.SelectionCharOffset instance.SelectionCharOffset = value
/** @property */ public int get_SelectionCharOffset () /** @property */ public void set_SelectionCharOffset (int value)
public function get SelectionCharOffset () : int public function set SelectionCharOffset (value : int)
文字オフセットを指定する数値。


このプロパティの値は、-2000 から 2000 までの範囲であることが必要です。
このプロパティが 0 に設定されている場合、テキストはベースライン上に表示されます。正の数を指定した場合、ベースラインから指定した数のピクセル分だけ上方向に離れた位置に、選択されているテキストが表示されます。負の数を指定した場合、ベースラインから指定した数のピクセル分だけ下方向に離れた位置に、選択されているテキストが表示されます。このプロパティを使用して、テキストを上付き文字または下付き文字として指定できます。
テキストが選択されていない場合、現在のカーソル位置、およびカーソル位置以降にユーザーが入力するすべてのテキストにオフセットが適用されます。プロパティの値が変更されるまで、またはカーソル位置をコントロール内の別の場所に移動するまでの間は、この文字セットが適用されます。
コントロール内でテキストが選択されている場合は、選択されているテキスト、およびテキストを選択した後に入力したすべてのテキストに対して、このプロパティの値が適用されます。このプロパティを使用すると、数値式などで使用される上付きや下付きのテキストを作成できます。

SelectionCharOffset プロパティを使用して、RichTextBox 内で上付きや下付きのテキストを指定する方法を次のコード例に示します。この例では、richTextBox1 という名前の RichTextBox コントロールがフォームに追加されている必要があります。
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
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: 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.set_SelectionFont(new Font("Lucinda Console", 12)); // Set the foreground color of the text. richTextBox1.set_SelectionColor(Color.get_Purple()); // Set the baseline text. richTextBox1.set_SelectedText("10"); // Set the CharOffset to display superscript text. richTextBox1.set_SelectionCharOffset(10); // Set the superscripted text. richTextBox1.set_SelectedText("2"); // Reset the CharOffset to display text at the baseline. richTextBox1.set_SelectionCharOffset(0); richTextBox1.AppendText("\n\n"); // Change the forecolor of the next text selection. richTextBox1.set_SelectionColor(Color.get_Blue()); // Set the baseline text. richTextBox1.set_SelectedText("77"); // Set the CharOffset to display subscript text. richTextBox1.set_SelectionCharOffset(-10); // Set the subscripted text. richTextBox1.set_SelectedText("3"); // Reset the CharOffset to display text at the baseline. richTextBox1.set_SelectionCharOffset(0); } //WriteOffsetTextToRichTextBox

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からRichTextBox.SelectionCharOffset プロパティを検索する場合は、下記のリンクをクリックしてください。

- RichTextBox.SelectionCharOffset プロパティのページへのリンク