如何清除RichTextBox中的文本内容 [英] How to clear text content in RichTextBox

查看:452
本文介绍了如何清除RichTextBox中的文本内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在RichTextBox中获取文本后,我想清除文本。我该怎么做?

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);


推荐答案

尝试创建 TextRange 包含 RichBoxText 内容,然后将 Text 设置为空字符串:

Try to create a TextRange with RichBoxText content, then set Text to empty string:

TextRange txt = new TextRange(richtxtSNotice.Document.ContentStart, richtxtSNotice.Document.ContentEnd);
txt.Text = "";

这篇关于如何清除RichTextBox中的文本内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆