As for button1.click apply an if loop so that when the button is pressed, the code is executed, for example: if the button is pressed, then assign the value in textBox1 to 'a'. What form should I write it in?
|
1 answer
A double click on the button will automatically create a handler for you, in which you will add the behavior you need. For your example, something like this will be:
void button1_Click(object sender, EventArgs e) { a = textBoxName.Text; } It's not entirely clear why you added the if keyword to the question and also called it a cycle. I can only assume that you want to do some behavior, depending on the button you clicked, but at the same time in one developer. For such an implementation, you need to select all the necessary buttons and again, automatically create one handler for them all. To determine which of the buttons was pressed, you need to set the sender event parameter to the type of the button and "look" by its properties.
var btn = sender as Button; ... |
ifO_o - Specter