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

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

RichTextBox.SelectionColor プロパティ

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

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

Dim instance As RichTextBox
Dim value As Color

value = instance.SelectionColor

instance.SelectionColor = value
public Color SelectionColor { get; set;
 }
public:
property Color SelectionColor {
    Color get ();
    void set (Color value);
}
/** @property */
public Color get_SelectionColor ()

/** @property */
public void set_SelectionColor (Color value)
public function get SelectionColor
 () : Color

public function set SelectionColor
 (value : Color)

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

解説解説
使用例使用例

RichTextBox コントロールで現在選択されているテキストの色、または現在のカーソル位置以降入力されるテキストの色を指定するための ColorDialog をユーザー表示するコード例次に示します。この例では、コード内で定義されているメソッドが、richTextBox1 という名前の RichTextBox コントロール保持している Form クラス追加されている必要があります

Public Sub ChangeMySelectionColor()
    Dim colorDialog1 As New
 ColorDialog()
    
    ' Set the initial color of the dialog to the current text color.
    colorDialog1.Color = richTextBox1.SelectionColor
    
    ' Determine if the user clicked OK in the dialog and that the color
 has
    ' changed.
    If (colorDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK)
 _
        And Not(colorDialog1.Color.Equals(richTextBox1.SelectionColor))
 Then
        
        ' Change the selection color to the user specified color.
        richTextBox1.SelectionColor = colorDialog1.Color
    End If
End Sub

public void ChangeMySelectionColor()
{
   ColorDialog colorDialog1 = new ColorDialog();

   // Set the initial color of the dialog to the current text color.
   colorDialog1.Color = richTextBox1.SelectionColor;

   // Determine if the user clicked OK in the dialog and that the color
 has changed.
   if(colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK
 && 
      colorDialog1.Color != richTextBox1.SelectionColor)
   {
      // Change the selection color to the user specified color.
      richTextBox1.SelectionColor = colorDialog1.Color;
   }
}

public:
   void ChangeMySelectionColor()
   {
      ColorDialog^ colorDialog1 = gcnew ColorDialog;
      
      // Set the initial color of the dialog to the current text color.
      colorDialog1->Color = richTextBox1->SelectionColor;
      
      // Determine if the user clicked OK in the dialog and that the color
 has changed.
      if ( colorDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK
 &&
         colorDialog1->Color != richTextBox1->SelectionColor )
      {
         // Change the selection color to the user specified color.
         richTextBox1->SelectionColor = colorDialog1->Color;
      }
   }
public void ChangeMySelectionColor()
{
    ColorDialog colorDialog1 = new ColorDialog();

    // Set the initial color of the dialog to the current text color.
    colorDialog1.set_Color(richTextBox1.get_SelectionColor());

    // Determine if the user clicked OK in the dialog and that the color
 
    // has changed.
    if (colorDialog1.ShowDialog() == 
        System.Windows.Forms.DialogResult.OK && 
        colorDialog1.get_Color() != richTextBox1.get_SelectionColor()) {
            // Change the selection color to the user specified color.
            richTextBox1.set_SelectionColor(colorDialog1.get_Color());
    }
} //ChangeMySelectionColor
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

「RichTextBox.SelectionColor プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS