In word processing, we often use fonts, and now we're going to make the most common font dialog box.
Font dialog box (fontdialog) Common Properties Showcolor control whether the color options are displayed allowscriptchange whether font character set font is displayed in the dialog box font allowverticalfonts whether vertical fonts can be selected Color in the dialog box to select whether to display errors when the font does not exist MaxSize the maximum font size minsize selectable fontmustexist scriptsonly display excludes OEM and symbol fonts showapply Show the Apply button showeffects whether the underline, strikethrough, font color options ShowHelp Display the Help button
Second, the Font dialog box (FontDialog) event
Apply when you click the "Apply" button to handle events helprequest when you click on the "Help" button to handle events
Third, the implementation of the Code
private void Fontdialogbtn_click (object sender, System.EventArgs e)
{
FontDialog fontdialog=new FontDialog ();
Fontdialog.color=richtextbox1.forecolor;
Fontdialog.allowscriptchange=true;
Fontdialog.showcolor=true;
if (Fontdialog.showdialog ()!=dialogresult.cancel)
{
richtextbox1.selectionfont=fontdialog.font;//changes the text currently selected to a font
}
}
The above code sets the selected text to the font in the current FontDialog dialog box.