honar abubakr

honar abubakr

  • NA
  • 73
  • 110.3k

disable all form buttons in a given duration?

Mar 10 2014 9:09 AM
I have a form in C# which has 4 buttons. I would like to disable all 4 buttons after a given duration of time, for example in 1 or 2 minutes. I searched in Google and found this code but it does not seem to work:
private System.Timers.Timer aTimer = new System.Timers.Timer(60) { AutoReset = false };
 
protected void Timer2_Tick(object sender, EventArgs e)
{ aTimer = new System.Timers.Timer(60);
 aTimer.Interval = 60; double counter = aTimer.Interval;
 counter
++; if (counter >= 60) {
 lib_bt
.Enabled = false;
 MessageBox.Show("Time Up!");
}
}

Answers (3)