Hello Everyone,
I have a timer that starts when a button is clicked on Form1. When the time elapses Form2 appears. On Form2 I want to stop the timer and restart it from a button on Form2 however the timer does not stop.
Here is my code for Form1:
public Form1()
{
InitializeComponent();
}
public Form2 frm2;
private void start_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Start();
timer1.Tick += new EventHandler(timer1_Tick);
}
public void timer1_Tick(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show();
}
Here is the code for Form2
public Form2()
{
InitializeComponent();
}
public Form1 frm1;
private void Form2_Load(object sender, EventArgs e)
{
}
private void restart_Click(object sender, EventArgs e)
{
frm1 = new Form1();
frm1.timer1.Enabled = false;
}
I would appreciate any help with this. (I can stop the timer is the buttons are on the same Form)
Thanks in advance,
SubProf