I have
Form1
and
Form2
.
I have a
Timer
in
Form1
, named
timer
.
Now, when the user clicks on the Pause button in
Form1
,
Form2
pops up, and the timer pauses.
When the user clicks on
button1
on
Form2
,
Form2
will close and the timer is supposed to continue running, but right now I can't make it happen.
Here's what I've tried so far:
On
Form1
:
private void btnPause_Click(object sender, EventArgs e)
{
timer.Stop();
new Form2(this).ShowDialog();
}
public void startTimer()
{
timer.Start();
}
And on
Form2
:
Form f1;
Form1 form1 = new Form1();
public Form2(Form1 f)
{
this.f1 = f;
}
private void button1_Click(object sender, EventArgs e)
{
form1.startTimer();
this.Close();
}
I'm referencing since there's also another button on
Form2
that when clicked will close
Form2
and
Form1
and will show another form.
I'm not sure if I should actually instantiate
Form1
, but I can't seem to access
startTimer()
through
f1
.
What would be the best approach to solve this?