How to set default font settings when opening font dialog

Sudip Bhatt 2,276 Reputation points
2020-10-31T10:25:58.157+00:00

This is my code and this way i am opening font dialog. how could i open font dialog with default font settings?
i want to set Font Name, Font Style, Font Size and underline etc when opening font dialog.

if (fontDlg.ShowDialog() == DialogResult.OK)
                 {
                     FontName = fontDlg.Font.Name;
                     FontStyle = fontDlg.Font.Style.ToString();
                     FontSize = fontDlg.Font.Size.ToString();
                     //if (FontSize.Contains("."))
                     //    FontSize = FontSize.Split('.')[0];

                     UnderLine = fontDlg.Font.Underline;
                     IsFontChanged = true;
                 }
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,879 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 83,541 Reputation points
    2020-10-31T11:10:49.633+00:00

    For example =>

    FontDialog fontDialog1 = new FontDialog();
    fontDialog1.Font = new System.Drawing.Font("Times New Roman", 10.0F, System.Drawing.FontStyle.Bold);
    if (fontDialog1.ShowDialog() == DialogResult.OK)
    {
        // code...
    }