Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Richtextbox text

Posted on 2005-03-02
Medium Priority
Last Modified: 2010-04-16
How can I display a text document within a richtextbox and it honor the line returns.  I have a document formatted like so:

"This is line 1\nthis is line2\nthis is line 3\tthis is a tab\nthis is line 4";

How can I display this string appropriately within a form.  Preferrably using a richtextbox.

Question by:gvector1
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
  • 2

Accepted Solution

AaronReams earned 2000 total points
ID: 13442735
Hi gvector1,

By default, the richeditbox should accept \n and insert a line return in its place.  

            string s = "This is line 1\nthis is line2\nthis is line 3\tthis is a tab\nthis is line 4";
            richTextBox1.Text = s;

This is line 1
this is line2
this is line 3    this is a tab
this is line 4

Is that not working for you?

Regards -A.R
LVL 10

Expert Comment

ID: 13443001
What is your Richtextbox displaying?

Author Comment

ID: 13443769
Thank you all.  It was my fault.  I didn't realize until A.R's sample what I was doing wrong.  I was using @ in front of the string.  Once I removed @, it worked fine.  Thanks for the assistance.

Expert Comment

ID: 13443808
No problem.   Cheers -A.R.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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