locked
Remove Font Size in Font dialog box RRS feed

  • Question

  • Am working on .Net v2.0 application. I have a specific requirement as not to show font size 11 inside the font dialog box I launch. Is there a way to achieve it. Please advice. Thanks in advance.
    -------------kings--------------
    Monday, May 23, 2011 9:22 AM

Answers

  • Hi

    Font Dialog Box is a packaged control in c#. You cannot performance that. But you can customize your own Font Dialog in either Windows form or Wpf.

    Here is a Font Dialog Box Demo using Windows Presentation Foundation (WPF).

    This sample application produces a dialog box that allows the user to customize values of font properties, for example, FontStyle, FontWeight, and FontSize. It also demonstrates techniques for creating a modal dialog box using Windows Presentation Foundation (WPF).

    http://msdn.microsoft.com/en-us/library/ms771765.aspx

    private ICollection<FontFamily> _familyCollection;     // see FamilyCollection property
        private string _defaultSampleText;
        private string _previewSampleText;
        private string _pointsText;
        private bool _updatePending;                // indicates a call to OnUpdate is scheduled
        private bool _familyListValid;               // indicates the list of font families is valid
        private bool _typefaceListValid;              // indicates the list of typefaces is valid
        private bool _typefaceListSelectionValid;          // indicates the current selection in the typeface list is valid
        private bool _previewValid;                 // indicates the preview control is valid
        private Dictionary<TabItem, TabState> _tabDictionary;    // state and logic for each tab
        private DependencyProperty _currentFeature;
        private TypographyFeaturePage _currentFeaturePage;
        private static readonly double[] CommonlyUsedFontSizes = new double[]
        {
          3.0,  4.0,  5.0,  6.0,  6.5,
          7.0,  7.5,  8.0,  8.5,  9.0,
          9.5,  10.0, 10.5, 11.0, 11.5,
          12.0, 12.5, 13.0, 13.5, 14.0,
          15.0, 16.0, 17.0, 18.0, 19.0,
          20.0, 22.0, 24.0, 26.0, 28.0, 30.0, 32.0, 34.0, 36.0, 38.0,
          40.0, 44.0, 48.0, 52.0, 56.0, 60.0, 64.0, 68.0, 72.0, 76.0,
          80.0, 88.0, 96.0, 104.0, 112.0, 120.0, 128.0, 136.0, 144.0
        };
    

     

    Hope this can help you.

    This is some parts of code. You can define any font size in this array. You may also implement in windows form.
    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Cookie Luo Monday, June 6, 2011 8:42 AM
    Wednesday, May 25, 2011 7:33 AM