从Richtextbox控件读取文本时保留隐藏文本 [英] Preserve hidden text while reading text from Richtextbox control

查看:103
本文介绍了从Richtextbox控件读取文本时保留隐藏文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WPF的richtextbox控件。在我的RTF文本中,隐藏了一些文本。我要隐藏文字的RTF文字如下所示

I am using richtextbox control of WPF. In my RTF text, some of the texts are hidden. My RTF text to hide text is as below 

@"{\rtf1\ansi \v " + <text to hide> + "\v0}";

我使用以下代码片段来读取richtextbox控件中的RTF文本:

I use following code snippet in order to read RTF text from the richtextbox control :

            TextRange tr = new TextRange(mainRTB.Document.ContentStart, mainRTB.Document.ContentEnd);
            using (MemoryStream stream = new MemoryStream())
            {
                tr.Save(stream, DataFormats.Rtf);
                stream.Seek(0, SeekOrigin.Begin);
                using (StreamReader reader = new StreamReader(stream))
                {
                    this.RtfText = reader.ReadToEnd();
                }
            }

(此处,"mainRTB"是richtextbox控件的名称)



当我检查"RtfText"时属性,我没有看到我在richtextbox中插入的隐藏文本。我正在阅读RichTextbox控件的方式有什么问题吗?我想保留RTF文本中的隐藏文字。 

(Here, "mainRTB" is the name of the richtextbox control)

When I check the "RtfText" property, I don't see the hidden text which I have inserted in richtextbox. Is there any problem in the way I'm reading the RichTextbox control? I want to preserve the hidden text in the RTF text. 

谢谢,

Krunal C

推荐答案

你好KrunalC,

Hi KrunalC,

根据你的描述,你说你在mainRTB richtextbox中隐藏了一些文字,现在你想从mainRTB读取文本到RtfText richtextbox,但是你也没有在RtfTextbox中看到隐藏文本,我是对的吗?

According to your description, you said that you hide some text in mainRTB richtextbox, and now you want to read text from mainRTB into RtfText richtextbox, but you also don't see the hide text in RtfTextbox, am I right?

你能告诉我你是怎么隐藏的吗?富文本框中的文字在这里?

Can you tell me how you hide text in richtextbox here?

最好的问候,

Cherry


这篇关于从Richtextbox控件读取文本时保留隐藏文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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