How can I implement simultaneous pressing of two Button ?
The task is as follows:
- if
Button1pressed, then whenButton1pressed, the message " Button1 + Button3 " is displayed ; - if the
Button2button is pressed, the message " Button2 + Button4 " is displayed whenButton4pressed.
Suppose there is such a code:
private void Category1_Click(object sender, EventArgs e) { if((Control)sender == Button1) { if((Control)sender == Button3) { MessageBox.Show("Button1+Button3"); } else if((Control)sender == Button4) { MessageBox.Show("Button1+Button4"); } } if((Control)sender == Button2) { if((Control)sender == Button4) { MessageBox.Show("Button2+Button4"); } } } The code problem is that the conditional construct if((Control)sender == Button3) does not work (due to the fact that after clicking on Button3 Button1 not pressed). So, you need to make sure that pressing Button1 saved until, for example, Button2 pressed. Please help.