是这样的,我的程序里面有两个窗体:
form1、form2.
当关闭form1的时候我希望form1在关闭过程中等待4秒钟,让form2显示一些消息出来,让用户看到。
请问用timer该怎么做?
好像thread.sleep(4000)不行,它只把form2定住了,没有让form2把消息显示出来。
form1、form2.
当关闭form1的时候我希望form1在关闭过程中等待4秒钟,让form2显示一些消息出来,让用户看到。
请问用timer该怎么做?
好像thread.sleep(4000)不行,它只把form2定住了,没有让form2把消息显示出来。
解决方案 »
- 在线等,,请教大家一个问题,,急急急
- vs2010和vs2008的区别
- 囧了,用ODBC从mySQL取数据 DataGridView显示中文乱码了。求解决办法
- 求救一个sql问题!
- [技术分享]C#中使用IFELanguage进行分词和注音处理
- 请问高手们一个关于父子窗体的问题!!!!
- 学习C#,有没有一本类似学习Java的《Think in Java》程度的书?顶者有分!
- SqlCommand 如何序列化
- 如何选中treeView中某一项同时传递这一项对应的两个参数?
- 请问谁有制作插件的经验?
- 过几天要去南京文思创新面试了,有没有什么建议之类的????
- 程序第一次运行时,委托的字体颜色渐变效果不佳
直接
form2.showsth()
然后继续关闭不就行了
这个你用哪里了? 可以的呀
你在form_closing事件中用呢
应该可以啊。
{
if(timer1.enable = false
{
e.cancel = true 取消关闭事件
messagebox.show("4秒后关闭!")
timer1.Enable = ture;
}
}timer1_ticket事件
this.close()
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
this.FormClosing += new FormClosingEventHandler(frm2.RecievedForm1CloseEvent);
frm2.Show();
}
}
}
然后在form2中处理form1的关闭事件
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} public void RecievedForm1CloseEvent(object sender, FormClosingEventArgs e)
{
this.label1.Text = "form1正在关闭中......";
if (MessageBox.Show("你真的要关闭form1吗?","请确认!",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)!= DialogResult.OK)
{
e.Cancel = true;
return;
}
}
}
}