-2

I'm making a Time Notification App with visual studio winform that will pop up a form message when the time is equal to time in my txt document. And my problem is I want to show message label in pop up form containing text in my other txt document. It's look like this.

int state = 1;
String[] schedule = System.IO.File.ReadAllLines(@"C:\loc\schedule12.txt");

Label TextBalloonLabel = new Label();

this.TextBalloonLabel.Text = dailySchedule[state];

In schedule String. schedule String[1] is "Good Work\nBreak Time" And in the label it show "Good Work\nBreak Time" too. But I want to add enter in label. How to do that ??

Thanks.

DovahkiiND
  • 17
  • 4
  • 3
    This has been dicussed before: https://stackoverflow.com/questions/13295116/add-newline-to-labels-text-at-design-time – Jan Mattsson Jun 24 '17 at 05:47
  • Yes but not in runtime. I want to change it in runtime @JanMattsson – DovahkiiND Jun 24 '17 at 05:50
  • 1
    What event would happen to have the label change? If the user presses a button, you could change the label in code at that time. However, if it is a “Label” component on your form and you want to allow the users to edit this “label” at run time then it is no longer a `Label`… it’s a `TextBox`. – JohnG Jun 24 '17 at 06:40

2 Answers2

1

You need Environment.NewLine.

So you can do it like this:

label1.Text = "test" + Environment.NewLine + "testNewLine";

This approach should be cross platform btw.

S_D
  • 226
  • 1
  • 8
0

like this?

label1.Text = @"test
testNewLine";
Dan
  • 34
  • 2