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.
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;
在设计时将Timer的Enabled
属性设置为false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.