• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 710
  • 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
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.

 
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

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

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