给你个小例子看看
[C#] 纯文本查看 复制代码 public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Interval = 10 * 1000;
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
Form2 f2 = new Form2();
f2.timer = timer1;
f2.ShowDialog();
}
}
[C#] 纯文本查看 复制代码 public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
//弹出窗体的定时控件对象
public Timer timer = null;
//知道了按钮
private void button1_Click(object sender, EventArgs e)
{
timer.Enabled = true;
this.Close();
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
|