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

Dim instance As RichTextBox Dim value As Color value = instance.SelectionColor instance.SelectionColor = value
/** @property */ public Color get_SelectionColor () /** @property */ public void set_SelectionColor (Color value)
現在選択されているテキストまたはカーソル位置以降に入力されるテキストに適用される色を表す Color。

現在選択されているテキストに複数の色が指定されている場合、このプロパティは Color.Empty を返します。テキストが現在選択されていない場合、このプロパティに指定されたテキストの色は、現在のカーソル位置と、カーソル位置以降にコントロールに入力されるすべてのテキストに適用されます。プロパティの値が異なる色に変更されるまで、またはカーソル位置をコントロール内の別の場所に移動するまでの間は、このテキストの色の設定が適用されます。
コントロール内でテキストが選択されている場合は、選択されているテキスト、およびテキストを選択した後に入力したすべてのテキストに対して、このプロパティの値が適用されます。このプロパティを使用して、RichTextBox 内のテキストの色を変更できます。
コントロール内のテキストを太字にするには、SelectionFont プロパティを使用して、太字フォント スタイルが指定されている新しいフォントを割り当てます。

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

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.SelectionColor プロパティを検索する場合は、下記のリンクをクリックしてください。

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