RichTextBox.SelectionCharOffset プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RichTextBox.SelectionCharOffset プロパティの意味・解説 

RichTextBox.SelectionCharOffset プロパティ

コントロールテキストが、ベースラインより上に上付き文字として表示されるのか、ベースラインより下に下付き文字として表示されるのかを示す値を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Property SelectionCharOffset As
 Integer
Dim instance As RichTextBox
Dim value As Integer

value = instance.SelectionCharOffset

instance.SelectionCharOffset = value
public int SelectionCharOffset { get;
 set; }
public:
property int SelectionCharOffset {
    int get ();
    void set (int value);
}
/** @property */
public int get_SelectionCharOffset ()

/** @property */
public void set_SelectionCharOffset (int
 value)
public function get SelectionCharOffset
 () : int

public function set SelectionCharOffset
 (value : int)

プロパティ
文字オフセット指定する数値

例外例外
例外種類条件

ArgumentException

指定した値が -2000 未満であるか、2000超えてます。

解説解説

このプロパティの値は、-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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からRichTextBox.SelectionCharOffset プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRichTextBox.SelectionCharOffset プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRichTextBox.SelectionCharOffset プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

RichTextBox.SelectionCharOffset プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RichTextBox.SelectionCharOffset プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS