我这里有 3 个按钮。
当我单击按钮 1 时,它将禁用按钮 1,然后启用第二个按钮,然后与到达最后一个按钮的过程相同。但我认为我的代码有问题。当我单击第一个按钮时它不会禁用
button1 被启用,而 button2 和 3 在加载时被禁用。
private void groupBox1_Enter(object sender, EventArgs e)
{
Button btn = sender as Button;
if (btn == button1)
{
button1.Enabled = false;
button2.Enabled = true;
button3.Visible = false;
button3.Enabled = false;
MessageBox.Show("button 1 disabled");
}
else if (btn == button2)
{
button1.Enabled = false;
button2.Enabled = false;
button3.Visible = true;
button3.Visible = true;
MessageBox.Show("button 2 disabled");
}
else if (btn == button3)
{
button1.Enabled = false;
button2.Enabled = false;
button3.Visible = false;
button3.Visible = false;
MessageBox.Show("button 3 disabled");
}
}