CuteEditor for .NET

Font Size Dropdown Customization

Font Size Dropdown Customization


The Font Size dropdown of CuteEditor by default displays a predefined set of font Sizes. 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 FontSize element which contains the configuration information for the Font Size dropdown within CuteEditor.  By default, it contains the following font sizes:

 

 

You can modify the FontSize element to create your own font size list.

Example 1:


<
FontSize>
      <item text="1 (8pt)" value="1" />
    
<item text="2 (10pt)" value="2" />
     
<item text="5 (18pt)" value="5" />
</FontSize>

Now the FontSize dropdown contains only 1, 2and 5.


 

Example 2:

<FontSize>
      <item text="10px" value="10px" />
    
<item text="12px" value="12px" />
     
<item text="14px" value="14px" />
</FontSize>

Now the FontSize dropdown contains only 10x, 12px and 14px.


 

 

 


2: Programmatically Populate the Font Size Dropdown:

C# Example:

if (!IsPostBack) { 
CuteEditor.ToolControl toolctrl=Editor1.ToolControls["FontSize"];
if(toolctrl!=null) {
CuteEditor.RichDropDownList dropdown=(CuteEditor.RichDropDownList)toolctrl.Control;
//the first item is the caption
CuteEditor.RichListItem richitem=dropdown.Items[0];
//clear the items from configuration files
dropdown.Items.Clear();
//add the caption
dropdown.Items.Add(richitem);
//add value only
dropdown.Items.Add("1");
//add text and value
dropdown.Items.Add("2 (10pt)","2");
//add html and text and value
dropdown.Items.Add("<span style= 'font-size:18pt'>5 </span>(18pt)","5(18pt)","5");
}
}


VB Example:

If Not Page.IsPostBack Then
  If Not Editor1.ToolControls("FontSize") Is Nothing Then

      Dim dropdown As CuteEditor.RichDropDownList
      Dim richitem As CuteEditor.RichListItem

      dropdown = DirectCast(Editor1.ToolControls("FontSize").Control, CuteEditor.RichDropDownList)

      'the first item is the caption
      richitem = dropdown.Items(0)

      'clear the items from configuration files
      dropdown.Items.Clear()

      'add the caption
      dropdown.Items.Add(richitem)

      'add value only
      dropdown.Items.Add("1")

     'add text and value
      dropdown.Items.Add("2 (10pt)","2")

      'Add html and text and value
      dropdown.Items.Add("<span style='font-size:18pt'>5 </span>(18pt)", "5 (18pt)", "5")

  End If
End If