日期:2014-05-17 浏览次数:20819 次
//看你心急,写一个参考吧
//Form1有一个按钮,点击就显示Form2,显示3秒就关闭Form2
//Form1中button事件
System.Windows.Forms.Timer timer=new System.Windows.Forms.Timer();
int times = 0;
Form2 frm = null;
private void button1_Click_1(object sender, EventArgs e)
{
frm = new Form2();
frm.WindowState = FormWindowState.Maximized;
frm.TopMost = true;
frm.Show();
timer.Enabled = true;
timer.Interval = 1000;
timer.Start();
timer.Tick += new EventHandler(timer_Tick);
}
void timer_Tick(object sender, EventArgs e)
{
times++;
if (times == 3)
{
frm.Close(); //关闭就这一句而已
timer.Stop();
}
}