PowerTools PlusPak for Windows Forms 8.0J
ForeColor プロパティ (RadioButtonItem)
使用例 

項目テキストの前景色を取得または設定します。
構文
Public Property ForeColor As Color
public Color ForeColor {get; set;}

プロパティ値

項目テキストの前景色を表すSystem.Drawing.Color。デフォルトは、RadioButtonItemGcRadioGroupBoxコントロールに関連付けられていない場合はSystem.Windows.Forms.Control.DefaultForeColorプロパティの値です。関連付けられている場合は、GcRadioGroupBox.ItemSettings.ForeColorプロパティで指定された色、またはGcRadioGroupBoxコントロールのSystem.Windows.Forms.Control.ForeColorプロパティで指定された色です。
解説

ForeColorプロパティはアンビエントプロパティです。つまり、このプロパティが設定されていない場合は、まずGcRadioGroupBox.ItemSettings.ForeColorプロパティから値が取得され、GcRadioGroupBox.ItemSettings.ForeColorも設定されていない場合は、関連付けられたGcRadioGroupBoxコントロールで指定された前景色から値が取得されます。

ForeColorプロパティを使用して、項目テキストの色を変更できます。このプロパティは、ある項目を他から区別するために異なる背景色と前景色の組み合わせを使用する場合に使用できます(背景色の設定にはBackColorプロパティを使用します)。たとえば、ForeColorプロパティをSystem.Drawing.Color.Redに設定して優先度の高い項目を区別することが可能です。

GcRadioGroupBoxコントロールのすべての項目の前景色を同じにする場合は、GcRadioGroupBox.ItemSettings.ForeColorプロパティを目的の色に設定します。こうすると、ForeColorが空でない色に設定されている項目を除くすべての項目テキストで、指定した色とフォントが使用されます。

使用例
次のサンプルコードは、RadioButtonItemオブジェクトを2つ作成してGcRadioGroupBoxコントロールに追加し、項目の一般的なプロパティを設定します。この例を実行するには、以下のコードをSystem.Windows.Forms.Formに追加し、ここで作成したメソッドをフォームのコンストラクターまたはSystem.Windows.Forms.Form.Loadイベントハンドラから呼び出す必要があります。
public void CreateMyGcRadioGroupBox()
{
    GcRadioGroupBox gcRadioGroupBox1 = new GcRadioGroupBox();
    gcRadioGroupBox1.Location = new Point(15, 15);
    gcRadioGroupBox1.Text = "MyGcRadioGroupBox";

    // Create an item.
    RadioButtonItem item = new RadioButtonItem();

    // Set the Text of RadioButtonItem.
    item.Text = "MyRadioButtonItem";

    // Set a new Font from the existing font.
    item.Font = new Font(item.Font, FontStyle.Bold);

    // Set the BackColor and ForeColor properties for RadioButtonItem.
    item.BackColor = Color.LightGreen;
    item.ForeColor = Color.LightPink;

    // Disable the item.
    item.Enabled = false;

    gcRadioGroupBox1.LayoutSettings.LayoutMode = LayoutMode.Absolute;
    // Set the location of the item.
    item.Location = new Point(15, 15);

    // Clone an item, modify its location and change its Enabled to true to enable the UI interaction.
    RadioButtonItem clonedItem = item.Clone() as RadioButtonItem;
    clonedItem.Location = new Point(15, 40);
    clonedItem.Enabled = true;

    gcRadioGroupBox1.Items.Add(item);
    gcRadioGroupBox1.Items.Add(clonedItem);
    this.Controls.Add(gcRadioGroupBox1);
}
Public Sub CreateMyGcRadioGroupBox()
    Dim gcRadioGroupBox1 As New GcRadioGroupBox()
    gcRadioGroupBox1.Location = New Point(15, 15)
    gcRadioGroupBox1.Text = "MyGcRadioGroupBox"

    ' Create an item.
    Dim item As New RadioButtonItem()

    ' Set the Text of RadioButtonItem.
    item.Text = "MyRadioButtonItem"

    ' Set a new Font from the existing font.
    item.Font = New Font(item.Font, FontStyle.Bold)

    ' Set the BackColor and ForeColor properties for RadioButtonItem.
    item.BackColor = Color.LightGreen
    item.ForeColor = Color.LightPink

    ' Disable the item.
    item.Enabled = False

    gcRadioGroupBox1.LayoutSettings.LayoutMode = LayoutMode.Absolute
    ' Set the location of the item.
    item.Location = New Point(15, 15)

    ' Clone an item, modify its location and change its Enabled to true to enable the UI interaction.
    Dim clonedItem As RadioButtonItem = TryCast(item.Clone(), RadioButtonItem)
    clonedItem.Location = New Point(15, 40)
    clonedItem.Enabled = True

    gcRadioGroupBox1.Items.Add(item)
    gcRadioGroupBox1.Items.Add(clonedItem)
    Me.Controls.Add(gcRadioGroupBox1)
End Sub
プラットフォーム

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

参照

RadioButtonItem クラス
RadioButtonItem メンバ
System.Drawing.Color
BackColor プロパティ
ForeColor プロパティ
System.Drawing.Color
BackColor プロパティ
ForeColor プロパティ

Send Feedback