Re: Adding hidden text to a rich text box control

  • Thread starter Thread starter =?ISO-8859-1?Q?Martin_M=FCller?=
  • Start date Start date
?

=?ISO-8859-1?Q?Martin_M=FCller?=

James Meehan said:
I have an application where I want to insert display text plus hidden
link information into a rich text box control. The link information
would be hidden by using the rtf format code (/v) for hiding text. If I
use the SelectedText filed, then the format codes are ignored. If I use
the SelectedRtf field, then nothing is inserted. Any help would be
appreciated.

I'm doing something similar at the moment and it works fine most of the time.
Just remember that your RichTextBox's Text/SelectedText property shows all
the text (including "{\v HiddenText}"), whereas the RichTextBox itself
does not render this "HiddenText".
Btw. you're using \v and not /v as stated, do you?

Anyway, take a look at this small code snipplet:

string strTextToHide = "Now you don't";
richTextBox1.Text = "Now you see me,.";
richTextBox1.Select(15,0);
richTextBox1.SelectedRtf = @"{\rtf1\ansi{\v "+strTextToHide+"}}";
MessageBox.Show("Text: "+richTextBox1.Text);
MessageBox.Show("RTF: "+richTextBox1.Rtf);

Hope this helps,
Martin Müller
 
Back
Top