Skip to content

Font Name dropdown Customization

CuteEditor for .NET

Font Name Dropdown Customization

The Font Name dropdown of CuteEditor by default displays a predefined set of font names. You can easily modify this default set using the following methods.

1. Edit Dropdown Configuration File (Common.config).

The dropdown configuration file (Common.config) can be found in the /CuteEditor/Configuration/Shared folder. In dropdown configuration file you can find the FontName element which contains the configuration information for the Font Name dropdown within CuteEditor. By default, it contains the following font names:



You can modify the FontName element to create your own font name list.

Example:
  1. <FontName>  
  2.    <item text="Arial" html="&lt;font size=3 face='Arial'&gt;Arial&lt;/font&gt;">Arial</item>  
  3.    <item text="Verdana" html="&lt;font size=3 face='Verdana'&gt;Verdana&lt;/font&gt;">Verdana</item>  
  4.    <item text="Comic Sans MS" html="&lt;font size=3 face='Comic Sans MS'&gt;Comic Sans MS&lt;/font&gt;">Comic Sans MS</item>  
  5.    <item text="Courier" html="&lt;font size=3 face='Courier'&gt;Courier&lt;/font&gt;">Courier</item>  
  6.    <item text="Georgia" html="&lt;font size=3 face='Georgia'&gt;Georgia&lt;/font&gt;">Georgia</item>  
  7.    <item text="Impact" html="&lt;font size=3 face='Arial'&gt;Impact&lt;/font&gt;">Impact</item>  
  8.    <item text="Lucida Console" html="&lt;font size=3 face='Lucida Console'&gt;Lucida Console&lt;/font&gt;">Lucida Console</item>  
  9.    <item text="Tahoma" html="&lt;font size=3 face='Tahoma'&gt;Tahoma&lt;/font&gt;">Tahoma</item>  
  10.    <item text="Times New Roman" html="&lt;font size=3 face='Times New Roman'&gt;Times New Roman&lt;/font&gt;">Times New Roman</item>  
  11.    <item text="Wingdings" html="&lt;font size=3 &gt;Wingdings&lt;/font&gt;">Wingdings</item>  
  12. </FontName>  



2. Programmatically Populate the Font Name

C# Example:
  1. if (!IsPostBack) {    
  2.    CuteEditor.ToolControl toolctrl=Editor1.ToolControls["FontName"];    
  3.    if(toolctrl!=null) {    
  4.       CuteEditor.RichDropDownList dropdown=(CuteEditor.RichDropDownList)toolctrl.Control;    
  5.       //the first item is the caption    
  6.       CuteEditor.RichListItem richitem=dropdown.Items[0];    
  7.       //clear the items from configuration files    
  8.       dropdown.Items.Clear();    
  9.       //add the caption   
  10.        dropdown.Items.Add(richitem);    
  11.       //add value only    
  12.       dropdown.Items.Add("Arial");    
  13.       //add text and value    
  14.       dropdown.Items.Add("Verdana","Verdana");    
  15.       //add html and text and value    
  16.       dropdown.Items.Add("<span style='font-family:Tahoma;font-size:12pt'>Tahoma</span>","Tahoma","Tahoma");    
  17.    }    
  18. }  

VB Example:

  1. If Not Page.IsPostBack Then  
  2.   If Not Editor1.ToolControls("FontName"Is Nothing Then  
  3.       Dim dropdown As CuteEditor.RichDropDownList   
  4.       Dim richitem As CuteEditor.RichListItem   
  5.       dropdown = DirectCast(Editor1.ToolControls("FontName").Control, CuteEditor.RichDropDownList)   
  6.       'the first item is the caption   
  7.       richitem = dropdown.Items(0)   
  8.       'clear the items from configuration files   
  9.       dropdown.Items.Clear()   
  10.       'add the caption   
  11.       dropdown.Items.Add(richitem)   
  12.       'add value only   
  13.       dropdown.Items.Add("Arial")   
  14.       'add text and value   
  15.        dropdown.Items.Add("Verdana","Verdana")   
  16.       'Add html and text and value   
  17.       dropdown.Items.Add("<span style='font-family:Tahoma;font-size:12pt'>Tahoma</span>""Tahoma""Tahoma")   
  18.   End If  
  19. End If