获取RichTextBox中的文本后,我想清除文本.我怎样才能做到这一点?
TextRange txt = new TextRange(richtxtSNotice.Document.ContentStart, richtxtSNotice.Document.ContentEnd);
MessageBox.Show(txt.Text);
Run Code Online (Sandbox Code Playgroud)
Cur*_*tis 96
使用以下内容:
_richTextBox.Document.Blocks.Clear();
Run Code Online (Sandbox Code Playgroud)
Adi*_*cov 12
这是一种简单的方法.
public void Clear()
{
richTextBox1.SelectAll();
richTextBox1.Selection.Text = "";
}
Run Code Online (Sandbox Code Playgroud)
尝试创建TextRange
包含RichBoxText
内容,然后设置Text
为空字符串:
TextRange txt = new TextRange(richtxtSNotice.Document.ContentStart, richtxtSNotice.Document.ContentEnd);
txt.Text = "";
Run Code Online (Sandbox Code Playgroud)