The RadRichTextEditor control exposes a full set of commands that are exposed through its Commands property. For each of the Formatting API methods there is a respective command.

Here is an example with a RadToggleButton control.

private RadToggleButton boldButton;

public Commands()
    this.boldButton = new RadToggleButton();
    this.boldButton.Text = "Bold";
    this.boldButton.Click += this.boldButton_Click;
    this.boldButton.Location = new Point(10, 10);

private void boldButton_Click(object sender, EventArgs e)

Private boldButton As RadToggleButton
Public Sub New()
    Me.boldButton = New RadToggleButton()
    Me.boldButton.Text = "Bold"
    AddHandler Me.boldButton.Click, AddressOf Me.boldButton_Click
    Me.boldButton.Location = New Point(10, 10)
End Sub
Private Sub boldButton_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub

Now, every time the button is clicked it will toggle the boldness of the current selection. The thing it won't do is to response to the current state of the selection. For example, if the context of the caret is a bold text, the button won't get automatically toggled. In order to implement this behavior you have to handle the ToggleStateChanged event of the ToggleBoldCommand. Here is an example.

private void Commands_Load(object sender, EventArgs e)
    this.radRichTextEditor1.Commands.ToggleBoldCommand.ToggleStateChanged += this.ToggleBoldCommand_ToggleStateChanged;

public void ToggleBoldCommand_ToggleStateChanged(object sender, StylePropertyChangedEventArgs<bool> e)
    this.boldButton.IsChecked = e.NewValue;

Private Sub Commands_Load(ByVal sender As Object, ByVal e As EventArgs)
    AddHandler Me.radRichTextEditor1.Commands.ToggleBoldCommand.ToggleStateChanged, AddressOf Me.ToggleBoldCommand_ToggleStateChanged
End Sub
Public Sub ToggleBoldCommand_ToggleStateChanged(ByVal sender As Object, ByVal e As StylePropertyChangedEventArgs(Of Boolean))
    Me.boldButton.IsChecked = e.NewValue
End Sub

Now, the button will respond to the current state of the selection.

richtexteditor-features-clipboard-support 001

In this article
Not finding the help you need? Improve this article