How to copy the content of a richtextbox to a multiline textbox

Hi all,

I want copy the text (only the text but with newline) from a richtextbox to a textbox.
the code:

TextBox.Text = RichTextBox.Text

doesn't work properly.
e.g.
Richtext:

This is
a multiline
Text

will displayed in the textbox as one line (see attached Picture)

Thanks for your help

Gerhard


form001.jpg
LVL 1
ghabicheAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
zonkermanConnect With a Mentor Commented:
You are getting linfeeds from the richtextbox control.  Use the following to replace the line feeds (ascii 10) with carriage return line feeds (asciee 10 and 13) into the textbox

TextBox1.Text = RichTextBox1.Text.Replace(Chr(10), Chr(13) + Chr(10))
0
 
BinuthCommented:
try this...

TextBox1.Text = RichTextBox1.Text.Replace("\n" , "\r\n");
0
 
ghabicheAuthor Commented:
Hi Binuth,

sorry, but this doesn't work.
Same behaviour as before.

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
BinuthCommented:
set TextBox's AcceptsReturn property to true
0
 
ghabicheAuthor Commented:
also the same
0
 
BinuthCommented:
Ohh....  can you put post the output of  RichTextBox1.Text from debug window ?
0
 
tiagosalgadoCommented:
Try TextBox1.Text = RichTextBox1.Text.Replace("\n" , Environment.NewLine);
0
 
ghabicheAuthor Commented:
For better testing I have attached the Testcase
0
 
ghabicheAuthor Commented:
For better testing I have attached the Testcase
0
 
tiagosalgadoCommented:
Have you set textbox Multiline property to true?

textBox1.Text = richTextBox1.Text.Replace("\n",Environment.NewLine);
0
 
ghabicheAuthor Commented:
Zonkerman, Thank you this is what I want
0
All Courses

From novice to tech pro — start learning today.