You have a few problems:
- You need to use an event
Load, not a button click handler. - You must set the interval
10000to 10 seconds to wait. - You are using a local variable for the timer instance. This makes it difficult for you to access the timer later. Make a timer instance instead of a form member.
- Remember to stop the clock after running the form or try to open every 10 seconds.
In other words, something like this:
private Timer tm;
private void Form1_Load(object sender, EventArgs e)
{
tm = new Timer();
tm.Interval = 10 * 1000;
tm.Tick += new EventHandler(tm_Tick);
tm.Start();
}
private void tm_Tick(object sender, EventArgs e)
{
tm.Stop();
Form2 frm = new Form2();
frm.Show();
this.Hide();
}
source
share