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

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

プロパティ値

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

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

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

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

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

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

    // Set the Text of CheckBoxItem.
    item.Text = "MyCheckBoxItem";

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

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

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

    gcCheckedGroupBox1.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.
    CheckBoxItem clonedItem = item.Clone() as CheckBoxItem;
    clonedItem.Location = new Point(15, 40);
    clonedItem.Enabled = true;

    gcCheckedGroupBox1.Items.Add(item);
    gcCheckedGroupBox1.Items.Add(clonedItem);
    this.Controls.Add(gcCheckedGroupBox1);
}
Public Sub CreateMyGcCheckedGroupBox()
    Dim gcCheckedGroupBox1 As New GcCheckedGroupBox()
    gcCheckedGroupBox1.Location = New Point(15, 15)
    gcCheckedGroupBox1.Text = "MyGcCheckedGroupBox"

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

    ' Set the Text of CheckBoxItem.
    item.Text = "MyCheckBoxItem"

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

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

    ' Disable the item.
    item.Enabled = False

    gcCheckedGroupBox1.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 CheckBoxItem = TryCast(item.Clone(), CheckBoxItem)
    clonedItem.Location = New Point(15, 40)
    clonedItem.Enabled = True

    gcCheckedGroupBox1.Items.Add(item)
    gcCheckedGroupBox1.Items.Add(clonedItem)
    Me.Controls.Add(gcCheckedGroupBox1)
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

参照

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

Send Feedback