如何从WPF RichTextBox中删除特定字符串(如果字符串存在)?
为了重新解释我的问题,以下WinForm RichTextBox版本的WPF等价物是什么:
richTextBox1.Text = "aaabbbccc";
richTextBox1.Text = richTextBox1.Text.Replace("bbb", "");
Run Code Online (Sandbox Code Playgroud)
谢谢!
这是一种方法:
TextRange textRange = new TextRange(
richTextBox.Document.ContentStart,
richTextBox.Document.ContentEnd
);
textRange.Text = textRange.Text.Replace("Text", "Document");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
728 次 |
| 最近记录: |