- This topic shows the working or implementation of Font Dialog used in C# programming.
- With the help of font dialog, you can change font size, font style while at C# programming running.
- Tools needed: Button1 (Button1), RichTextBox1 (RichTextBox1), FontDialog1 (FontDialog1)
C#.NET – Working of Font Dialog in C#
- C# is an Object Oriented Programming language from Microsoft that mainly combines the computing power of C++ with the programming ease of Visual Basic.
- C# is mainly based on C++.
- The most recent version is C#4.0.
- C# language is simple, modern, general-purpose, object-oriented language.
FontDialog Class – Working of Font Dialog in C#
- Help the user to choose a font from among those installed on the local computer.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
- Syntax for Font Dialog
|
1 2 3 |
// Declaration public class FontDialog : CommonDialog { } |
CommonDialog.ShowDialog Method – Working of Font Dialog in C#
- Help to run a common dialog box with a default owner.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
- Syntax for ShowDialog
|
1 2 3 |
// Declaration public void ShowDialog(void As, void DialogResult) { } |
FontDialog.Font Property – Working of Font Dialog in C#
- FontDialog.Font help to get or set the selected font.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
- Syntax for FontDialog.Font
|
1 2 |
'Declaration Public Property Font As Font |
RichTextBox Class – Working of Font Dialog in C#
- Helps to represent a windows rich text box.
- Syntax
|
1 2 3 4 5 6 |
// Declaration [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] [DockingAttribute(DockingBehavior.Ask)] public class RichTextBox : TextBoxBase { } |
Working of Font Dialog in C# – Change font of a text
|
1 2 3 4 5 6 7 8 |
private void button1_Click(object sender, EventArgs e) { if (FontDialog1.ShowDialog() == DialogResult.OK) { RichTextBox1.Font = FontDialog1.Font; } } |
Working of Font Dialog in C# – Change font of a selected text
|
1 2 3 4 5 6 7 8 |
private void button1_Click(object sender, EventArgs e) { if (FontDialog1.ShowDialog() == DialogResult.OK) { RichTextBox1.SelectionFont = FontDialog1.Font; } } |
if you have any suggestions or doubts, please contact us…
Working of Font Dialog in C#






