Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-10
11
Medium Priority
?
300 Views
Last Modified: 2012-05-05
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
Comment
Question by:ghabiche
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 14

Expert Comment

by:Binuth
ID: 22685588
try this...

TextBox1.Text = RichTextBox1.Text.Replace("\n" , "\r\n");
0
 
LVL 1

Author Comment

by:ghabiche
ID: 22685633
Hi Binuth,

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

0
 
LVL 14

Expert Comment

by:Binuth
ID: 22685647
set TextBox's AcceptsReturn property to true
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:ghabiche
ID: 22685665
also the same
0
 
LVL 14

Expert Comment

by:Binuth
ID: 22685682
Ohh....  can you put post the output of  RichTextBox1.Text from debug window ?
0
 
LVL 8

Expert Comment

by:tiagosalgado
ID: 22685830
Try TextBox1.Text = RichTextBox1.Text.Replace("\n" , Environment.NewLine);
0
 
LVL 1

Author Comment

by:ghabiche
ID: 22685892
For better testing I have attached the Testcase
0
 
LVL 1

Author Comment

by:ghabiche
ID: 22685897
For better testing I have attached the Testcase
0
 
LVL 8

Expert Comment

by:tiagosalgado
ID: 22687057
Have you set textbox Multiline property to true?

textBox1.Text = richTextBox1.Text.Replace("\n",Environment.NewLine);
0
 
LVL 1

Accepted Solution

by:
zonkerman earned 500 total points
ID: 22694624
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
 
LVL 1

Author Closing Comment

by:ghabiche
ID: 31504942
Zonkerman, Thank you this is what I want
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question