Solved

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

Posted on 2008-10-10
11
290 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 125 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now