You can change MyFontDialog as follows:
public partial class MyFontDialog : Form { private FontListBox _fontListBox; private ListBox _fontSizeListBox; public MyFontDialog() { //InitializeComponent(); _fontListBox = new FontListBox(); _fontListBox.SelectedIndexChanged += OnfontListBoxSelectedIndexChanged; _fontListBox.Size = new Size(200, Height); Controls.Add(_fontListBox); _fontSizeListBox = new ListBox(); _fontSizeListBox.Location = new Point(_fontListBox.Width, 0); Controls.Add(_fontSizeListBox); } private void OnfontListBoxSelectedIndexChanged(object sender, EventArgs e) { _fontSizeListBox.Items.Clear(); Font font = _fontListBox.SelectedItem as Font; if (font != null) { foreach (FontStyle style in Enum.GetValues(typeof(FontStyle))) { if (font.FontFamily.IsStyleAvailable(style)) { _fontSizeListBox.Items.Add(style); } } } } }
It will create a list box aside from the font list with a list of available font styles. Regarding the choice of size, you can just add a list box with a hard-coded list of sizes: 8,9,10,11,12, 14,16,18,20,22,24,26,28,36,48 and 72, so same as the standard FontDialog, since we are dealing with true type fonts.
Simon mourier
source share