Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

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
0
ghabiche
Asked:
ghabiche
  • 5
  • 3
  • 2
  • +1
1 Solution
 
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
 
BinuthCommented:
set TextBox's AcceptsReturn property to true
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
zonkermanCommented:
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
 
ghabicheAuthor Commented:
Zonkerman, Thank you this is what I want
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now