Skip to content

Instantly share code, notes, and snippets.

@igoravl
Last active August 21, 2023 21:59
Show Gist options
  • Save igoravl/0f2ac3e71fe9e7142792 to your computer and use it in GitHub Desktop.
Save igoravl/0f2ac3e71fe9e7142792 to your computer and use it in GitHub Desktop.
Apply system font to Windows Forms Dialog
using System;
using System.Drawing;
using System.Windows.Forms;
namespace SampleForms
{
public partial class SampleForm : Form
{
public SampleForm()
{
InitializeComponent();
ApplySystemFont();
}
private void ApplySystemFont()
{
ApplySystemFontToControl(this);
}
private static void ApplySystemFontToControl(Control control)
{
control.Font = SystemFonts.MessageBoxFont;
foreach (Control childControl in control.Controls)
{
ApplySystemFontToControl(childControl);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment