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

フォントドロップダウンリスト内のグループの前景色を取得または設定します。
構文
Public Property ForeColor As Color
public Color ForeColor {get; set;}

プロパティ値

グループの前景色を表すSystem.Drawing.Color。デフォルトはSystem.Windows.Forms.Control.DefaultForeColorプロパティの値です。
解説
ForeColorプロパティはアンビエントプロパティです。ItemGroupStyleのアンビエントプロパティは、設定されていない場合、関連付けられたGcFontPickerコントロールから値が取得されます。たとえば、デフォルトでは、ItemGroupStyleプロパティのForeColorは関連付けられたGcFontPickerコントロールと同じになります。
使用例

次のサンプルコードは、GcFontPicker.ItemGroupStyleプロパティ上でForeColorプロパティを設定して、フォントドロップダウンリスト内のグループの前景色を設定します。この例を実行するには、以下のコードをSystem.Windows.Forms.Formに追加し、ここで作成したメソッドをコンストラクターまたはフォーム上の別のメソッドから呼び出す必要があります。

private void CreateGcFontPickerWithItemGroupStyle()
{
    // Create an instance of GcFontPicker control.
    GcFontPicker gcFontPicker = new GcFontPicker();

    // Initialize the Name and Location of the gcFontPicker.
    gcFontPicker.Name = "gcFontPicker";
    gcFontPicker.Location = new Point(10, 50);

    // Set the BackColor and ForeColor of the groups.
    gcFontPicker.ItemGroupStyle.BackColor = Color.Green;
    gcFontPicker.ItemGroupStyle.ForeColor = Color.Gold;

    // Set the Font of the groups.
    gcFontPicker.ItemGroupStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, GraphicsUnit.Point);

    // Set the caption of all fonts group.
    gcFontPicker.ItemGroupStyle.AllFontsText = "My All Fonts";

    // Set the caption of preferred fonts group.
    gcFontPicker.ItemGroupStyle.PreferredFontsText = "My Preferred Fonts";
    // Add some items to the preferred fonts in order to show the group.
    gcFontPicker.PreferredFonts.AddRange(new FontInfo[] 
    {
        gcFontPicker.AllFonts["MingLiU"],
        gcFontPicker.AllFonts["MS UI Gothic"],
    });

    // Set the caption of recently used fonts.
    gcFontPicker.ItemGroupStyle.RecentlyUsedFontsText = "My Recently Used Fonts";
    // Add some items to the recently used fonts in order to show the group.
    gcFontPicker.RecentlyUsedFonts.AddRange(new FontInfo[] 
    {
        gcFontPicker.AllFonts["Nina"],
        gcFontPicker.AllFonts["Vrinda"]
    });

    // adds gcFontPicker to the form.
    this.Controls.Add(gcFontPicker);
}
Private Sub CreateGcFontPickerWithItemGroupStyle()
    ' Create an instance of GcFontPicker control.
    Dim gcFontPicker As New GcFontPicker()

    ' Initialize the Name and Location of the gcFontPicker.
    gcFontPicker.Name = "gcFontPicker"
    gcFontPicker.Location = New Point(10, 50)

    ' Set the BackColor and ForeColor of the groups.
    gcFontPicker.ItemGroupStyle.BackColor = Color.Green
    gcFontPicker.ItemGroupStyle.ForeColor = Color.Gold

    ' Set the Font of the groups.
    gcFontPicker.ItemGroupStyle.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, GraphicsUnit.Point)

    ' Set the caption of all fonts group.
    gcFontPicker.ItemGroupStyle.AllFontsText = "My All Fonts"

    ' Set the caption of preferred fonts group.
    gcFontPicker.ItemGroupStyle.PreferredFontsText = "My Preferred Fonts"
    ' Add some items to the preferred fonts in order to show the group.
    gcFontPicker.PreferredFonts.AddRange(New FontInfo() {gcFontPicker.AllFonts("MingLiU"), gcFontPicker.AllFonts("MS UI Gothic")})

    ' Set the caption of recently used fonts.
    gcFontPicker.ItemGroupStyle.RecentlyUsedFontsText = "My Recently Used Fonts"
    ' Add some items to the recently used fonts in order to show the group.
    gcFontPicker.RecentlyUsedFonts.AddRange(New FontInfo() {gcFontPicker.AllFonts("Nina"), gcFontPicker.AllFonts("Vrinda")})

    ' adds gcFontPicker to the form.
    Me.Controls.Add(gcFontPicker)
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

参照

ItemGroupStyle クラス
ItemGroupStyle メンバ
System.Windows.Forms.Control.ForeColor
System.Windows.Forms.Control.ForeColor

Send Feedback