This project is read-only.

Detailed Documentation

Here are the classes & interfaces included in YARTE, and how to use them.


public void AddFontSizeSelector(IEnumerable<int> fontSizes)

This is a method that will add a Font Size Selector dropdown control to the HtmlEditor toolbar. FontSizes can only contain numbers 1 through 7, otherwise this method will throw an exception.

public void AddFontSelector(IEnumerable<string> fontNames)

This is a method that will add a Font Selector dropdown control to the HtmlEditor toolbar. Note that fontNames is a string collection, so you can put any font names you want into this collection, but note that the user will need that font installed on their computer, and of course if the resulting HTML is used elsewhere (like the web or in an email), the font must be installed on all client machines, so if I were you, I'd only use well-known fonts or fonts that you are sure will be around for the users.

public void AddToolbarItem(ToolStripItem toolStripItem)
public void AddToolbarItems(IEnumerable<ToolStripItem> toolStripItems)

These methods will add either one or a collection of ToolStripItems (buttons, comboboxes, etc) to the HtmlEditor toolbar, in the order given.

public void AddToolbarItem(IHTMLEditorButton toolbarItem)
public void AddToolbarItems(IEnumerable<IHTMLEditorButton> toolbarItems)

These methods will add either one or a collection of IHTMLEditorButton implementations to the HtmlEditor toolbar. See below for details on implementing IHTMLEditorButton.

public void AddToolbarDivider()

This just adds a divider to the HtmlEditor toolbar.

public bool ReadOnly

If you want to make the editor readonly (i.e. for a preview form or something), set this to true, but it's false by default.

public bool ShowToolbar

If you want to turn off the toolbar for whatever reason (again, maybe a preview form) set this to false, but it's true by default.

public string Html

This gets or sets the actual content & markup of the control. Note that the Html rendered is completely up to the MSHTML engine, so you might get weird stuff like 'font' tags and 'meta' tags and what not, so if you want nicer markup you may have to parse the output to clean it up.

public string InsertTextAtCursor

If you want to put in some text at the cursor position, use this property's setter. This is akin to 'SelectedText' of a RichTextBox, but it only inserts.


This interface gives you a (hopefully) convenient way to add custom buttons to the HtmlEditor toolbar, beyond the ones provided. Here are the methods/properties of the interface:

void IconClicked(HTMLEditorButtonArgs doc)

This is the method that will be invoked when your button is clicked. You can do anything you want, but most likely you'll need to use the supplied HTMLEditorButtonArgs object to do anything useful (see below).

Image IconImage { get; }

This is the image that will be used on the button.

string IconName { get; }

This will be the name of the button.

string IconTooltip { get; }

This will be the text that appears on the button tooltip.

string CommandIdentifier { get; }

This is the CommandIdentifier string. This is optional, but it can be used to determine which toolbar button(s) should appear as 'selected' or 'pressed' when the user's cursor is in the corresponding area. For instance, if the CommandIdentifier is 'Bold', then if the user's cursor is in a bolded area of content, then the bold button will appear as selected.


This is a simple struct with two fields:

public HtmlDocument Document

This is the underlying HtmlDocument that is used by the HtmlEditor. Typically, you'd use the ExecCommand method to perform some operation on the document (see: for more information).

public HtmlEditor Editor

This is the HtmlEditor control itself. You can use this to get screen location, the Html itself, or whatever other information you might need to write your button.

IHTMLEditorButton example

See for the ExecCommand parameters for this example.

    public class ItalicButton : IHTMLEditorButton
        public void IconClicked(HTMLEditorButtonArgs args)
            args.Document.ExecCommand(CommandIdentifier, false, null);

        public Image IconImage
            get { return Resources.italic; }

        public string IconName
            get { return "Italic"; }

        public string IconTooltip
            get { return "Italic"; }

        public string CommandIdentifier
            get { return "Italic"; }

Last edited Jul 19, 2010 at 3:52 AM by mattgroves, version 6


No comments yet.