After getting the text in the RichTextBox I want to clear the text. How can I do that?
TextRange txt = new TextRange(richtxtSNotice.Document.ContentStart, richtxtSNotice.Document.ContentEnd); MessageBox.Show(txt.Text);
The RichTextBox is similar to the TextBox, but it has additional formatting capabilities. Whereas the TextBox control allows the Font property to be set for the entire control, the RichTextBox allows you to set the Font, as well as other formatting properties, for selections within the text displayed in the control.
Step 2: Drag the RichTextBox control from the ToolBox and drop it on the windows form. You are allowed to place a RichTextBox control anywhere on the windows form according to your need. Step 3: After drag and drop you will go to the properties of the RichTextBox control to add text in the RichTextBox control.
The RichTextBox control enables you to display or edit flow content including paragraphs, images, tables, and more. This topic introduces the TextBox class and provides examples of how to use it in both Extensible Application Markup Language (XAML) and C#.
Use the following:
_richTextBox.Document.Blocks.Clear();
This is a simple way of doing it.
public void Clear() { richTextBox1.SelectAll(); richTextBox1.Selection.Text = ""; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With