Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-10
11
Medium Priority
?
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 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