Insert programatically content in sfRichTextEditor

What is the extension of possibles programatical interactions with RTE? I have to include a hyperlink and the content of its return. I am not able to do that. Is it possible, for instance, to create a table and insert the text inside of it and release the updated content to user? 


1 Reply

VR Vallarasu Ravichandran Syncfusion Team December 31, 2025 10:23 AM UTC

Hi Luciano Baron de Lima,

Thank you for contacting us!

We apologize for the delayed response. We have validated your query regarding programmatically inserting content into the SfRichTextEditor control, including adding hyperlinks, inserting the returned content of a link, and creating tables.

 

To achieve this, we recommend using the HtmlText property. With this property, you can set or bind HTML‑formatted text both initially and dynamically at runtime. This lets you insert links, tables, and any HTML content programmatically. Kindly refer to the API reference for further clarification:  HtmlText


Insert Hyperlink and Table via Toolbar

You can also insert hyperlinks and tables using the built-in toolbar items. When inserting a table, the content will be placed at the current cursor position.

For more details, refer to:

Code snippet programmatically inserting:

XAML

  <rte:SfRichTextEditor x:Name="richTextEditor"></rte:SfRichTextEditor>

 

C#

    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            // Insert hyperlink and table using HtmlText property
            richTextEditor.HtmlText = GetHtmlContent();
        }

        private string GetHtmlContent()
        {
            // Create HTML content with hyperlink and table
            string htmlContent = @"
<h1>Rich Text Editor Sample</h1>
<p>This is a <strong>sample document</strong> with various <em>formatted content</em> and a <a rel='nofollow' href='https://www.syncfusion.com'>hyperlink to Syncfusion</a>.</p>
<h2>Sample Data Table</h2>
<table border='1' cellpadding='5' cellspacing='0'>
    <thead>
        <tr style='background-color: #f0f0f0;'>
            <th>Product</th>
            <th>Category</th>
            <th>Price</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Laptop</td>
            <td>Electronics</td>
            <td>$999.99</td>
        </tr>
        <tr>
            <td>Mouse</td>
            <td>Accessories</td>
            <td>$29.99</td>
        </tr>
        <tr>
            <td>Keyboard</td>
            <td>Accessories</td>
            <td>$79.99</td>
        </tr>
        <tr>
            <td>Monitor</td>
            <td>Electronics</td>
            <td>$399.99</td>
        </tr>
    </tbody>
</table>
<p>For more information, visit <a rel='nofollow' href='https://www.syncfusion.com/maui-controls/maui-richtexteditor'>Syncfusion MAUI Rich Text Editor</a>.</p>";

            // Clean the HTML content by removing unwanted newlines and replacing double quotes with single quotes
            var cleanedHtml = Regex.Replace(htmlContent, @"[\n\r]|""", m => m.Value == "\"" ? "'" : "");
            return cleanedHtml;

        }
    }

 

For more details refer to official document: Basic Features in .NET MAUI Rich Text Editor | Syncfusion®

Please let us know if you need any further assistance or have additional questions. We're here to help!

 

Regards,

Vallarasu R.


Loader.
Up arrow icon