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

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

RichTextBox.SelectionFont プロパティ

現在選択されているテキストまたはカーソル位置フォント取得または設定します

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

Dim instance As RichTextBox
Dim value As Font

value = instance.SelectionFont

instance.SelectionFont = value
public Font SelectionFont { get; set;
 }
public:
property Font^ SelectionFont {
    Font^ get ();
    void set (Font^ value);
}
/** @property */
public Font get_SelectionFont ()

/** @property */
public void set_SelectionFont (Font value)
public function get SelectionFont
 () : Font

public function set SelectionFont
 (value : Font)

プロパティ
現在選択されているテキストまたはカーソル位置以降入力されるテキスト適用されるフォントを表す Font

解説解説
使用例使用例

RichTextBox コントロール内で選択されているテキストまたはカーソル位置以降入力されるテキストについて、現在設定されている太字フォント スタイル変更するコード例次に示します。この例では、コードFormメソッド内に含まれている必要がありますまた、richTextBox1 という名前の RichTextBox が、Form追加されている必要もあります

Private Sub ToggleBold()
   If Not richTextBox1.SelectionFont Is
 Nothing Then
      Dim currentFont As System.Drawing.Font
 = richTextBox1.SelectionFont
      Dim newFontStyle As System.Drawing.FontStyle

      If richTextBox1.SelectionFont.Bold = True
 Then
         newFontStyle = FontStyle.Regular
      Else
         newFontStyle = FontStyle.Bold
      End If

      richTextBox1.SelectionFont = New Font( _
         currentFont.FontFamily, _
         currentFont.Size, _
         newFontStyle _
      )
   End If
End sub
private void ToggleBold()
{
   if (richTextBox1.SelectionFont != null)
   {
      System.Drawing.Font currentFont = richTextBox1.SelectionFont;
      System.Drawing.FontStyle newFontStyle;

      if (richTextBox1.SelectionFont.Bold == true)
      {
         newFontStyle = FontStyle.Regular;
      }
      else
      {
         newFontStyle = FontStyle.Bold;
      }

      richTextBox1.SelectionFont = new Font(
         currentFont.FontFamily, 
         currentFont.Size, 
         newFontStyle
      );
   }
}
void ToggleBold()
{
   if ( richTextBox1->SelectionFont != nullptr )
   {
      System::Drawing::Font^ currentFont = richTextBox1->SelectionFont;
      System::Drawing::FontStyle newFontStyle;
      if ( richTextBox1->SelectionFont->Bold == true
 )
      {
         newFontStyle = FontStyle::Regular;
      }
      else
      {
         newFontStyle = FontStyle::Bold;
      }
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( currentFont->FontFamily,currentFont->Size,newFontStyle
 );
   }
}
private void ToggleBold()
{
    if (richTextBox1.get_SelectionFont() != null)
 {
        System.Drawing.Font currentFont = richTextBox1.get_SelectionFont();
        System.Drawing.FontStyle newFontStyle;

        if (richTextBox1.get_SelectionFont().get_Bold() == true)
 {
            newFontStyle = FontStyle.Regular;
        }
        else {
            newFontStyle = FontStyle.Bold;
        }

        richTextBox1.set_SelectionFont(
            new Font(currentFont.get_FontFamily(), 
            currentFont.get_Size(), newFontStyle));
    }
} //ToggleBold
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS