Stefan Cazacu

Stefan Cazacu

  • NA
  • 28
  • 27.2k

how to conditionally disable and enable multiple buttons

Sep 6 2013 9:32 AM

Hi. I'm trying to build a UI which makes use of about 18 buttons to fulfil certain tasks. The problem is if a button has been pressed before the previous command has finished executing it can cause problems. To solve the issue i'm blocking all the buttons while the command is executed. However, because in some cases the command needs to be turned off manually, that specific button cannot be disabled.

For example: I have to press button1 to turn on the motor and press it again to turn it off. While the motor is running all other buttons should be disabled.

My question is: Is there a more efficient way of disabling all buttons except the active one, rather than conditionally enabling/disabling each one? Thank you in advance. I am currently using this code:

 

 

 

 

private

 

void button_toggle()

 

{

btn_Finished.Enabled = !toggle;

btn_Do_Empty.Enabled = !toggle;

btn_Do_Fill_toSensor.Enabled = !toggle;

btn_Purge_Fill.Enabled = !toggle;

btn_Fill_Dome.Enabled = !toggle;

btn_Pulse_Reagent.Enabled = !toggle;

btn_Pulse_Standard.Enabled = !toggle;

toggle = !toggle;

}


 

 


Answers (4)