form2:
public Form2()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.textBox1.Text = Convert.ToString(Convert.ToInt32(this.textBox1.Text) + 1);
}
private void button1_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3();
form3.TimerObj = this.timer1;
form3.ShowDialog();
}
private void Form2_Load(object sender, EventArgs e)
{
this.textBox1.Text = "0";
timer1.Interval = 1000;
timer1.Start();
}
Form3:
public partial class Form3 : Form
{
Timer timer = null;
public Timer TimerObj
{
get { return timer; }
set { timer = value; }
}
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
TimerObj.Stop();
}
}