本文介绍了计时器在窗体上闪烁消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Windows窗体项目中,每当有一个调用长时间运行的方法时,我都会显示一个带有标签控件的小窗体,该控件说,请稍等,然后在长时间运行的调用之后隐藏该窗体.即
Hi,
In my windows form project, every time there is a call to a long running method, I show a small form which has a label control that says, please wait and then after the long running call I hide that form . i.e.
ShowForm();
LongRunningMethod();
HideForm();
问题:
在显示showForm
时如何使标签控件每秒闪烁一次?
谢谢
Question:
How can I make the label control to blink every second while the showForm
is being shown?
Thanks
推荐答案
Timer blinkTimer = new Timer();
blinkTimer.Interval = 1000;
blinkTimer.Tick += new EventHandler(blinkTimer_Tick);
blinkTimer.Start();
...
void blinkTimer_Tick(object sender, EventArgs e)
{
myBlinkingLabel.Visible = !myBlinkingLabel.Visible;
}
这篇关于计时器在窗体上闪烁消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!