Serialcoder en Français Serialcoder in English
TEL : +33 (0)9 72 13 15 17

Windows Forms FAQ resources

19. Windows Forms Common Dialogs

19.2 How do I use the FontDialog class to set a control's font?


It is straight-forward. Create an instance of the class and call its ShowDialog method.


FontDialog fontDialog1 = new FontDialog();
fontDialog1.ShowColor = true;
if(fontDialog1.ShowDialog() != DialogResult.Cancel )
{
textBox1.Font = fontDialog1.Font ;
textBox1.ForeColor = fontDialog1.Color;
}

textBox1.Text = "this is a test";