A label in form is displaying the count of timer. Now i want to stop,start and reset it using form 2. How can i do this.plz help
Forms are just classes, and the timer on Form 2 is an object inside that class.
You can change the Modifiers
property of your timer to public, and then instantiate Form 2 inside Form 1, call the Show()
method of Form 2, and then access your timer object which is now public.
So you have a project with 2 forms like so:
Create a button in Form 1 like so:
Place a timer object on Form 2 and change the access modifier like so:
Then put the following code under your button in form one:
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
f2.timer1.Enabled = true;
}
Now you can launch form 2 and access all of the properties on the timer on form 2 from form 1.
Does this help?