skyeshua
skyeshua

Reputation: 11

Enabling a timer when a button is pressed C#

I have two forms, form1 and form2. In form1 I have a button which, when pressed, will make form2 appear. In form2 I have a button which will enable a Timer control. The problem is that the timer is already enabled when form2 appears, even if I did not press the button yet.

Thank you for your time.

Upvotes: 0

Views: 2018

Answers (2)

Abbas
Abbas

Reputation: 14432

Set the Enabled - property of the timer to false by default, and set it to true when the button in Form2 is pressed.

Update:

You can do this in the Properties windows in the Designer of your form or you can do this through code, like this:

public Form2()
{
    InitializeComponent();
    timer1.Enabled = false;
}

//And in the button-event: timer1.Enabled = true;

Upvotes: 3

PraveenVenu
PraveenVenu

Reputation: 8337

Set Timer's Enabled property to false at the design time

Upvotes: 0

Related Questions