How can I create a program in C# that does the following: 1. Create a WindowsForm with a button and a label 2. When the button is pressed the label should change from "False" to "True" or vice-versa
I want the label's message to be displayed depending on the state of a boolean variable.
bool Light1 = false;
When I press the button, I want Light1 to become True and if I press it again it should become False.
The label shows a True or False message depending on Light1;
The problem I am facing is changing the label depending on Light1. The code that gets executed when I press the button is:
private void button1_Click(object sender, EventArgs e)
{
if (parametri.Light1 == false)
{
parametri.Light1 = true;
}
else
{
parametri.Light1 = false;
}
}
parametri is a class that contains one public bool Light1 variable that is initialized to False.
I would be grateful if someone could explain to me how I could make the connection between a label and the Light1 variable.