C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Here: In the example code for button1_Click, we call the ShowDialog method on the FontDialog instance.
C# program that opens FontDialog
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Show the dialog.
DialogResult result = fontDialog1.ShowDialog();
// See if OK was pressed.
if (result == DialogResult.OK)
{
// Get Font.
Font font = fontDialog1.Font;
// Set TextBox properties.
this.textBox1.Text = string.Format("Font: {0}", font.Name);
this.textBox1.Font = font;
}
}
}
}
Tip: The ShowEffects property can be set to True or False. If you set it to False, the left-hand control group will disappear.
Tip 2: If you disable ShowEffects, the color chooser drop-down will also be hidden.