C#在Windows窗体中,按钮不能单击两分钟,显示一条消息 [英] C# In Windows Form, Button Not Click Around two Minutes, Display a Message
本文介绍了C#在Windows窗体中,按钮不能单击两分钟,显示一条消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果在Windows窗体应用程序中某个特定按钮没有在两分钟内单击,我想显示一条消息以单击该按钮.请提出建议.
If In a windows form application a specific button not click around two minutes, I want to display a message to click he button. Please advise.
推荐答案
在表单上放置所需时间的计时器,然后在其打勾时向用户抛出一个消息框.
Place a timer on your form with the duration you want and then throw up a message box to the user when it ticks.
1.在类中创建一个bool值以检查按钮的状态(单击或未单击)
1.create a bool value in the class to check status of button(clicked or not clicked)
bool IsClicked = false;
2.如果单击按钮,则将IsClicked设置为true.因此在button.click中添加以下行.单击处理方法
2.set IsClicked to true if button is clicked.so add below line within button.click handling method
bool IsClicked = true;
3.添加以下内容以形成加载事件处理方法.
如果尚未设置IsClicked,它将启动计时器并显示一个消息框.
3.add following to form load event handling method.
It starts the timer and shows a messagebox if IsClicked is still not set.
Timer timer = new Timer();
timer.Start();
timer.Interval = 120000;
timer.Tick += new EventHandler((o, b) => {if(!IsClicked)MessageBox.Show("Please click the button");});
这篇关于C#在Windows窗体中,按钮不能单击两分钟,显示一条消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文