• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 738
  • Last Modified:

How do I add a vertical scroll bar to a label ?

I am outputting data to a label in a Windows App using C#.  Some of the data is rather long and cuts off at the bottom of the label.  How can I add a vertical scroll bar to it?

ptslv
0
ptslv
Asked:
ptslv
  • 5
  • 5
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
Scrollbars belongs to TextBox and not to Label.

Use a ReadOnly textbox instead.
0
 
ptslvAuthor Commented:
OK, emoreau.  I got the textbox working with the scroll bar, but now my output has lost it's formatting.  How do I get the line returns back?

ptslv
0
 
Éric MoreauSenior .Net ConsultantCommented:
is your Multiline property set to True?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
ptslvAuthor Commented:
yes
0
 
Éric MoreauSenior .Net ConsultantCommented:
Then you surely don't have real carriage return into your string.
0
 
ptslvAuthor Commented:
I am using "\n" in the string.
0
 
Éric MoreauSenior .Net ConsultantCommented:
try replacing \n with environment.newline
0
 
ptslvAuthor Commented:
emoreau-

I tried using "\r".  It trashes the formatting in the label and doesn't do any better in the textbox.

ptslv
0
 
Éric MoreauSenior .Net ConsultantCommented:
use this:

textBox1.Text = "line 1\nline2\nline3".Replace("\n",Environment.NewLine);
0
 
ptslvAuthor Commented:
emoreau,

I went back thru and replaced all the "\r" with Environment.NewLine and it worked like a charm.  Thanks!

ptslv
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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