Last active
August 21, 2023 21:59
-
-
Save igoravl/0f2ac3e71fe9e7142792 to your computer and use it in GitHub Desktop.
Apply system font to Windows Forms Dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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