Articles in this section
Category / Section

How to modify the content in UWP RichTextBoxAdv programmatically?

2 mins read

The SfRichTextBoxAdv’s Document Object Model allows you to create and manipulate the document programmatically similar to Microsoft Word automation.

The following code example demonstrates how to define a new document and add text through code behind.

C#

// Defines the document.
DocumentAdv documentAdv = new DocumentAdv();
 
// Defines and adds a section to the document.
SectionAdv sectionAdv = new SectionAdv();
 
// You can add any number of sections here.
documentAdv.Sections.Add(sectionAdv);
 
// Defines and adds a paragraph to the section.
ParagraphAdv paragraphAdv = new ParagraphAdv();
 
// You can add any number of paragraphs, tables here.
sectionAdv.Blocks.Add(paragraphAdv);
 
// Defines and add a span to the paragraph.
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world";
            
// You can add any number of spans, images and hyperlink fields here.
paragraphAdv.Inlines.Add(spanAdv);
 
// Define the document for SfRichTextBoxAdv control.
richTextBoxAdv.Document = documentAdv;

VB

' Defines the document.
Dim documentAdv As New DocumentAdv()
 
' Defines and adds a section to the document.
Dim sectionAdv As New SectionAdv()
 
' You can add any number of sections here.
documentAdv.Sections.Add(sectionAdv)
 
' Defines and adds a paragraph to the section.
Dim paragraphAdv As New ParagraphAdv()
 
' You can add any number of paragraphs, tables here.
sectionAdv.Blocks.Add(paragraphAdv)
 
' Defines and add a span to the paragraph.
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world"
 
' You can add any number of spans, images and hyperlink fields here.
paragraphAdv.Inlines.Add(spanAdv)
 
' Define the document for SfRichTextBoxAdv control.
richTextBoxAdv.Document = documentAdv

 

Conclusion

I hope you enjoyed learning about how to modify the content in UWP RichTextBoxAdv programmatically.

You can refer to our UWP RichTextBoxAdv feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our UWP RichTextBoxAdv example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied