Hi,
How to use timer control in C#?
Any example please? Thanks
|
Go4Expert Founder
|
![]() |
| 2May2007,14:15 | #2 |
|
1. Have the timer control in your application or have a variable of type Timer.
2. Assign a event to the Timer tick event. 3. Enable the timer and start when you think you need the event. 4. After sufficient time elapse your function will be called. |
|
Contributor
|
|
| 2May2007,14:19 | #3 |
|
I managed before you said above but thanks Shabbir. I did above now how to show current system time on the form at some specific position. Following is some sample of code I have
Code:
public Form1()
{
InitializeComponent();
// Instantiate the timer
timer1 = new Timer();
// Setup timer
timer1.Interval = 1000; //1000ms = 1sec
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Start();
}
Code:
private void timer1_Tick(object sender, EventArgs e)
{
if (sender == timer1)
{
DateTime.Now.ToLongDateString();
}
}
|

