Ich möchte eine Umschaltfläche erstellen, aber es bleibt bei On. Wie schalte ich die Taste von ein auf aus.Ein Aus-Taste bleibt bei On
private void Form2_Load(object sender, EventArgs e){
Button button = new Button();
button.Location = new Point(200, 30);
button.Text = "Off";
this.Controls.Add(button);
if (button.Text != "On")
{
button.Text = "On";
button.BackColor = Color.Green;
}
else if (button.Text == "On")
{
button.Text = "On";
button.BackColor = Color.Red;
}
}
ich es "off "" bleibt nach wie vor bei On" geändert haben. – discable10