winfrom弹出窗口用timer控件控制倒计时20秒后关闭
2007-04-05 10:12
465 查看
功能描述:
这个是我做自动注册软件的一部分功能.弹出子窗体,在子窗体上显示倒计时20秒(每一秒减一),如果用户在子窗体上的textbox中输入,则倒计时停止,否则到0的时候自动关闭子窗体.
代码如下:
private int count;
private void Form2_Load(object sender, System.EventArgs e)
{
//倒计时20秒
count = 0;
btm.Text = "";
this.timer1.Enabled=true;
this.timer1.Start();
}
private void timer1_Tick(object sender, System.EventArgs e)
{
Console.WriteLine(count);
count++;
this.d_time.Text="本窗体将在"+(20-count)+"秒以后关闭!";
if(this.btm.Text != "")
{
this.timer1.Stop();
}
else if(count==20)
{
this.timer1.Stop();
this.Close();
}
}
这个是我做自动注册软件的一部分功能.弹出子窗体,在子窗体上显示倒计时20秒(每一秒减一),如果用户在子窗体上的textbox中输入,则倒计时停止,否则到0的时候自动关闭子窗体.
代码如下:
private int count;
private void Form2_Load(object sender, System.EventArgs e)
{
//倒计时20秒
count = 0;
btm.Text = "";
this.timer1.Enabled=true;
this.timer1.Start();
}
private void timer1_Tick(object sender, System.EventArgs e)
{
Console.WriteLine(count);
count++;
this.d_time.Text="本窗体将在"+(20-count)+"秒以后关闭!";
if(this.btm.Text != "")
{
this.timer1.Stop();
}
else if(count==20)
{
this.timer1.Stop();
this.Close();
}
}
相关文章推荐
- JS弹出框、对话框、提示框,JS关闭窗口、关闭页面和JS控制页面跳转
- 关闭浏览器窗口是弹出提示框,并且可以通过函数控制其失效。
- 关闭浏览器窗口弹出提示框并且可以控制其失效
- javaFX 可控制自动关闭时间的弹出提示窗口
- 倒计时自动关闭弹出窗口
- 倒计时自动关闭弹出窗口
- 关闭浏览器窗口弹出提示框并且可以控制其失效
- 父窗口控制弹出窗口快捷键ctrl+c关闭
- layer 打开关闭弹出窗口与获取父窗口值
- 使用js实现关闭js弹出层的窗口
- 点击按钮,弹出一个可关闭的层窗口,网页背景变灰
- Flex控制弹出窗口拖动范围示例代码
- 使用UI Automation实现自动化测试--5 (Winfrom和WPF中弹出和关闭对话框的不同处理方式)
- Jquery实现倒计时跳转到指定页面或关闭窗口
- js实现浏览器右下角弹出提示信息窗口,几秒后自动关闭
- 屏蔽IE弹出"您查看的网页正在试图关闭窗口,是否关闭此窗口"的方法
- 弹出新窗口,填写数据,提交后,关闭该弹出窗口,刷新父页面
- 自动弹出窗口,并定时关闭
- winfrom 中关闭登陆窗口显示先窗口