GrapeCity.Win.Pickers 名前空間 > GcFontPicker クラス : ShowRecentlyUsedFonts プロパティ |
次のサンプルコードは、GcFontPickerコントロールの最近使用したフォントを独自に定義する方法を示します。また、ShowRecentlyUsedFontsプロパティの使用方法も示します。このサンプルコードを実行するには、以下のコードをSystem.Windows.Forms.Formプロジェクトに追加し、ここで作成したメソッドをコンストラクターまたはフォーム上の別のメソッドから呼び出します。
private void CreateGcFontPickerWithRecentlyUsedFonts() { // 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 Recently used fonts. gcFontPicker.ShowRecentlyUsedFonts = true; gcFontPicker.RecentlyUsedFontsCount = 5; gcFontPicker.RecentlyUsedFonts.AddRange(new FontInfo[] { gcFontPicker.AllFonts["MingLiU"], gcFontPicker.AllFonts["MS UI Gothic"], gcFontPicker.AllFonts["Nina"], gcFontPicker.AllFonts["Vrinda"] }); gcFontPicker.ItemGroupStyle.RecentlyUsedFontsText = "My Recently Used Fonts"; // Set the SelectedFont to the last item of RecentlyUsedFonts. gcFontPicker.SelectedFontInfo = gcFontPicker.RecentlyUsedFonts[gcFontPicker.RecentlyUsedFonts.Count - 1]; // adds gcFontPicker to the form. this.Controls.Add(gcFontPicker); }
Private Sub CreateGcFontPickerWithRecentlyUsedFonts() ' 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 Recently used fonts. gcFontPicker.ShowRecentlyUsedFonts = True gcFontPicker.RecentlyUsedFontsCount = 5 gcFontPicker.RecentlyUsedFonts.AddRange(New FontInfo() {gcFontPicker.AllFonts("MingLiU"), gcFontPicker.AllFonts("MS UI Gothic"), gcFontPicker.AllFonts("Nina"), gcFontPicker.AllFonts("Vrinda")}) gcFontPicker.ItemGroupStyle.RecentlyUsedFontsText = "My Recently Used Fonts" ' Set the SelectedFontInfo to the last item of RecentlyUsedFonts. gcFontPicker.SelectedFontInfo = gcFontPicker.RecentlyUsedFonts(gcFontPicker.RecentlyUsedFonts.Count - 1) ' 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