Formatting via a Sample UI
If you want to allow the user to edit and format the content of RadRichTextBox, you have to create UI and use the API exposed by RadRichTextBox. The API exposes methods (like ToggleBold(), ToggleItalic() etc.) that modify the text in the control when called. Example 1 shows a sample code that creates UI for making the text bold, italic and underlined.
Example 1: Creating Formatting UI
Example 2 demonstrates how you can call the corresponding API methods from code-behind.
Example 2: Using the Formatting API in Code-Behind
The UI should also respond when the caret is on a document position where the text is modified. For example, the BoldButton should be toggled if the caret is on bold text. This can be done by handling the ToggleStateChanged event as demonstrated in Example 3.
Example 3: Changing the Toggle State of a Button Depending on the Caret Position
You can download a runnable project with the code illustrated in this article from our SDK repository here.
Figure 1: Changing the Toggle State of a Button Depending on the Caret Position
RadRichTextBox comes with a fully functional formatting UI out of the box. You can read more on the following links - RadRichTextBoxRibbonUI, ContextMenu, SelectionMiniToolBar.