$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
How to Put up DropDown Font of HtmlEditor Using C#
Home > How to > HtmlEditor DropDowns Font
Like any other common text editing applications, the PerHtmlEditor Control also offers rich font controlling tools, including the font style controlling tool, font size controlling tool and real font size controlling tool. The above mentioned font related tools will be placed at the toolbar of the html editor in the form of drop-downs.
The drop-down includes a pre-defined collection of functional items and users can easily select one item by opening the drop-down list. In this tutorial page, you will know how to enable three popularly used font related drop-downs using C# code programmatically.

C# Code for Creating Drop-down Collection of Font Names

The PerHtmlEditor Control offers a list of pre-defined set of font styles, including Arial, Courier New, Garamond, Georgia, MS Sans Serif, Segoe UI, Tahoma, Times New Roman and Verdana. And developers are allowed to set these fonts using the FontName Collection.
Now, with following C# programming example, we will guide you how to create the drop-down collection of font names in html editor.
PerHtmlEditor1.FontNames.Add("Arial");
PerHtmlEditor1.FontNames.Add("Courier New");
PerHtmlEditor1.FontNames.Add("Garamond");

C# Code for Creating Drop-down of Font Sizes

In this section, we will guide you to create a drop-down of font sizes. The PerHtmlEditor Control allows developers to populate seven font size items, ranging from value 1 to value 7. Following C# sample code is used to illustrate how to add the font sizes collection to the html editor programmatically.
PerHtmlEditor1.FontSizes.Add("1");
PerHtmlEditor1.FontSizes.Add("2");
PerHtmlEditor1.FontSizes.Add("3");
PerHtmlEditor1.FontSizes.Add("4");
PerHtmlEditor1.FontSizes.Add("5");
PerHtmlEditor1.FontSizes.Add("6");
PerHtmlEditor1.FontSizes.Add("7");

C# Code for Creating Drop-down of Real Font Sizes

Different from the drop-down of font sizes, this drop-down collection of real font sizes will display the font sizes in pixels and points. Similarly, here we attach a C# sample to show you how to use create the drop-down collection of real font sizes using programming method.
PerHtmlEditor1.RealFontSizes.Add("8px");
PerHtmlEditor1.RealFontSizes.Add("9px");
PerHtmlEditor1.RealFontSizes.Add("10px");
PerHtmlEditor1.RealFontSizes.Add("11px");

Related Tutorials for Other Supported HtmlEditor Drop-downs

Apart from this font drop-down, the PerHtmlEditor Control for ASP.NET AJAX also allows users to create other commonly used drop-downs. Following links will take you to detailed programming guiding pages on how to add these drop-downs to html editor using C# code.
  • How to create html editor drop-down collection of paragraph styles using C# code
  • How to create html editor drop-down collection of colors using C# code
  • How to create html editor drop-down collection of css styles using C# code
  • How to create html editor drop-down collection of inserting tables using C# code
ASP.NET AJAX UI Controls