The Timer User Control is a basic control that implements a timer, that raises an event at user-defined intervals.
Drag the control from the Toolbox and drop it anywhere in the form. The place where you drop it within the form is not important, as the control has no visual behavior.
Whenever the Enabled property is set to True and the Interval property is greater than zero, the Elapsed event is raised at intervals based on the Interval property setting.
For example, if you want to automatically redirect to a new page after 5 seconds, you should:
- Set the interval property to 5000
- Enable the timer in the Start event
- Program the Elapsed event with something like this:
The control has the following properties:
- Control name: The name of the control
- Interval: Gets or sets the time, in milliseconds, before the Elapsed event is raised.
- Enabled (available at runtime only): Gets or sets whether the timer is running (default is False).
By default, the timer is disabled, so if you want it to start running it as the page is loaded, you will have to enable it in the Start event:
Timer1.Enabled = True
If you want to change the Interval property to a running timer, you will have to disable and re-enable it, so the change takes effect.