Escape characters in RichTextBox....

S

Sinex

Hi !
I have a form. The form has a textbox and a richtextbox.
There is a button also. When the button is clicked,
whatever text was typed into the text box, must be copied
to the richtextbox.

At runtime, I enter the following string into the text
box:
Hi\nHello\nHow\nDo\nYou\nDo

Then I click the button. In the richtextbox I am expecting
Hi
Hello
How
Do
You
Do

But what I get is:
Hi\nHello\nHow\nDo\nYou\nDo


Ne idea to workaround this probs?

....Sinex
 
M

Michael \(michka\) Kaplan [MS]

When entered through the keyboard as text into the control, they are not
escape characters -- they are just regular characters. So what you see is
expected. Are you looking to create code that will treat text as something
to parse and thus will treat the backslash as a character escaping function
generically?
 
T

T.Fischer

-----Original Message-----
Hi !
I have a form. The form has a textbox and a richtextbox.
There is a button also. When the button is clicked,
whatever text was typed into the text box, must be copied
to the richtextbox.

At runtime, I enter the following string into the text
box:
Hi\nHello\nHow\nDo\nYou\nDo

Then I click the button. In the richtextbox I am expecting
Hi
Hello
How
Do
You
Do

But what I get is:
Hi\nHello\nHow\nDo\nYou\nDo


Ne idea to workaround this probs?

....Sinex
.
use

String s1=Regex.Unescape(textBox1.Text);

and put s1 in your RichTextBox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top