How do I remove a specific string from WPF RichTextBox (if the string exist)?
To rephrase my question, what is the WPF equivalent of the following WinForm RichTextBox version:
richTextBox1.Text = "aaabbbccc";
richTextBox1.Text = richTextBox1.Text.Replace("bbb", "");
Thanks!
This is one way of doing it:
TextRange textRange = new TextRange(
richTextBox.Document.ContentStart,
richTextBox.Document.ContentEnd
);
textRange.Text = textRange.Text.Replace("Text", "Document");
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