处理按钮单击顺序c# [英] Handling sequence of button clicks c#
本文介绍了处理按钮单击顺序c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望按照特定顺序点击两个不同的按钮后弹出一个图像。 我该怎么做?
I want an image to pop up after I click on two different buttons in a certain order. How do I do this?
推荐答案
在第一个按钮的点击事件中设置一个标志,表示它已被点击,然后检查标志第二个按钮的点击事件。
Set a flag in the first button's click event to say that it has been clicked, then check the flag in the second button's click event.
bool firstButtonClicked = false;
private void button1_Click(object sender, EventArgs e)
{
firstButtonClicked = true;
}
private void button2_Click(object sender, EventArgs e)
{
if(firstButtonClicked)
{
// Pop the image up here.
}
// Reset the flag.
firstButtonClicked = false;
}
这篇关于处理按钮单击顺序c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文