使用计时器隐藏标签和文本框 [英] Hiding Label and TextBox using Timer
本文介绍了使用计时器隐藏标签和文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在2分钟后运行该应用程序,则textbox1
和label1
将变得不可见.如果再次移动鼠标指针,则textbox1
和label
变为可见.现在,我需要的是2分钟后再次显示textbox1
和label1
,并且如果我移动鼠标指针,则它应该再次可见.
此过程应该一直重复进行,直到我关闭应用程序为止.
If I run the application after 2 minutes my textbox1
and label1
become invisible. If I move the mouse pointer again textbox1
and label
become visible. Now what I need is after 2 minutes again the textbox1
and label1
need to invisible and if I move the mouse pointer it should visible again.
This process should repeat continuously until I close the application.
推荐答案
在您发布代码后,很明显,我们可以确定您的问题.
Its very clear for us to identify your problem after you post your code.
public Form1()
{
InitializeComponent();
// Set the timer interval here
timer1 = new Timer();
timer1.Interval = 2000; // means 2 seconds
// timer1.Interval = 2 * 60 * 1000 // means 2 minutes
timer1.Tick += timer1_Tick;
}
private void timer1_Tick(object sender, EventArgs e)
{
textbox1.Visible = false;
label1.Visible = false;
timer1.Stop();
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
label1.Visible = true;
textBox1.Visible = true;
// Restart Timer
timer1.Stop();
timer1.Start();
}
添加(编辑)
Added (edit)
private void Form1_Load(object sender, EventArgs e)
{
// Automatic start timer at Form Load
timer1.Start();
}
这篇关于使用计时器隐藏标签和文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文