Reputation: 13338
I have a label
that gets filled with two strings
, very short after each other, so only the last string
will be visible in the .Text property
of the label
.
I want to have a pause of 1.5 seconds between those strings
, example:
string strMessage1 = "ONE";
string strMessage2 = "TWO";
Label.Text = strMessage1;
//Pause of 1.5 seconds
Label.Text = strMessage2;
Now I tried setting up a timer
, the following way:
private void FillString()
{
stringTimer = new System.Timers.Timer();
stringTimer.Interval = 1500;
stringTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnStringTimerElapsed);
Label.Text = strMessage1;
stringTimer.Start();
}
private void OnStringTimerElapsed(object sender, EventArgs e)
{
Label.Text = strMessage2;
}
But it only shows the first string
in the label
and doesn't do anything with the second. What should I do?
Upvotes: 2
Views: 2779
Reputation: 2542
After assigning the second string value, invalidate the label object.
Label1.Invalidate();
Upvotes: 1