PowerTools PlusPak for Windows Forms 8.0J
PreferredFonts プロパティ
使用例 

お気に入りフォントグループにフォント名項目として表示されるFontInfoオブジェクトのコレクションを取得します。
構文
Public ReadOnly Property PreferredFonts As FontInfoCollection
public FontInfoCollection PreferredFonts {get;}

プロパティ値

お気に入りFontInfoオブジェクトを表すFontInfoCollection
解説

ShowPreferredFontsがtrueの場合、ドロップダウンリストにお気に入りフォントグループが表示され、PreferredFontsに格納されたFontInfoオブジェクトがお気に入りフォントグループのフォント名項目として上から順に表示されます。

PreferredFontsプロパティを使用すると、お気に入りFontInfoオブジェクトのリストへの参照を取得できます。この参照を使用して、コレクション内のFontInfoオブジェクトを追加または削除したり、オブジェクトの数を確認したりできます。このコレクションに対して実行できるタスクの詳細については、FontInfoCollectionクラスのリファレンストピックを参照してください。

使用例

次のサンプルコードは、GcFontPickerコントロールのお気に入りフォントを独自に定義する方法を示します。このサンプルコードを実行するには、以下のコードをSystem.Windows.Forms.Formプロジェクトに追加し、ここで作成したメソッドをコンストラクターまたはフォーム上の別のメソッドから呼び出します。

private void CreateGcFontPickerWithPreferredFonts()
{
    // 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);

    // Initialize PreferredFonts.
    gcFontPicker.ShowPreferredFonts = true;
    gcFontPicker.PreferredFonts.AddRange(new FontInfo[] 
    {
        new FontInfo("MingLiU", "Represents MingLiU Font"),
        new FontInfo("MS UI Gothic","Represents MS UI Gothic Font"),
        new FontInfo("Nina","Represents Nina Font"),
        new FontInfo("Vrinda","Represents Vrinda Font"),
    });
    gcFontPicker.ItemGroupStyle.PreferredFontsText = "My Preferred Fonts";

    // Set the SelectedFont to the first item of PreferredFonts.
    gcFontPicker.SelectedFontInfo = gcFontPicker.PreferredFonts[0];

    // adds gcFontPicker to the form.
    this.Controls.Add(gcFontPicker);
}
Private Sub CreateGcFontPickerWithPreferredFonts()
    ' 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)

    ' Initialize PreferredFonts.
    gcFontPicker.ShowPreferredFonts = True
    gcFontPicker.PreferredFonts.AddRange(New FontInfo() {New FontInfo("MingLiU", "Represents MingLiU Font"), New FontInfo("MS UI Gothic", "Represents MS UI Gothic Font"), New FontInfo("Nina", "Represents Nina Font"), New FontInfo("Vrinda", "Represents Vrinda Font")})
    gcFontPicker.ItemGroupStyle.PreferredFontsText = "My Preferred Fonts"

    ' Set the SelectedFontInfo to the first item of PreferredFonts.
    gcFontPicker.SelectedFontInfo = gcFontPicker.PreferredFonts(0)

    ' 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

参照

GcFontPicker クラス
GcFontPicker メンバ
ShowPreferredFonts プロパティ
ShowPreferredFonts プロパティ

Send Feedback