Reputation: 87
i created a Timer Control and set some properties
private void MyForm_Load(object sender, EventArgs e)
{
timerClose.Enabled = true;
timerClose.Interval = 10000;
timerClose.Start();
}
One Event of Timer
private void timerClose_Tick(object sender, EventArgs e)
{
this.Text = timerClose.Interval.ToString();
}
but do not have happened. How to update it ?
Upvotes: 0
Views: 485
Reputation: 53595
Does your form display "10000" about 10 seconds after it opens and after that the form's caption doesn't change?
If so, your program is doing what it's supposed to be doing. When your Timer fires it changes your form's caption to the Timer's Interval
property, which you've set to 10000. That value doesn't change so your form's caption won't change.
If your intention is to have your form's caption increment with every Timer tick create a class level counter that you increment on each tick, like this:
int _tickCounter = 0;
private void timerClose_Tick(object sender, EventArgs e) {
this.Text = (++_tickCounter * timerClose.Interval).ToString();
}
This code will change the form's caption to "10000" 10 seconds after the form opens and will increment this value by 10000 every 10 seconds after that.
Upvotes: 1
Reputation: 1919
Just make sure your timer is enabled and the event handler is assigned properly
Upvotes: 1