【发布时间】:2020-04-26 12:32:00
【问题描述】:
我目前正在为一个学校项目开发一个小程序,但似乎根本找不到解决方案。
我一直在处理带有显示文本标签的 Windows 窗体。然后是两个按钮。如果您单击了这些按钮中的任何一个,则另一个将被隐藏,并且已单击按钮的文本会发生变化。
现在我想检查这些按钮的文本是否已更改,然后再次单击现在更改的按钮关闭应用程序。以下是我目前所拥有的。
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "You wake up.\n\n"+
"What would you like to do?";
button1.Text = "I'd like to eat some cerials!";
button2.Text = "I need to go to the bathroom!";
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "You stand up, go to the kitchen and eat some cerials. Nice!";
button1.Text = "Hurray, you ate some cerials";
button2.Hide();
// if (button1.TextChanged +=)
// {
//
// }
}
private void button2_Click(object sender, EventArgs e)
{
label1.Text = "You don't finde the Bathroom in this house and have to use the garden.";
button2.Text = "You get arested afterwars!";
button1.Hide();
}
public void EndGame()
{
Close();
}
有没有办法真正做到这一点,还是我需要一些解决方法?
【问题讨论】: