[英]How to check when the timer tick event occurs
我需要在关闭前制作一个 5000 毫秒可见的启动画面。 我将 5000 传递给我的 SplashScreen 表单构造函数并设置timer1.Interval = time
。 我似乎无法在网上找到一个直截了当的答案,而且我对计时器没有太多经验。 我假设我需要显示启动屏幕,启动计时器,检查timer1.Tick
发生,然后关闭表单,但我不知道如何执行此操作的语法。
private void Form1_Load(object sender, EventArgs e)
{
SplashScreen splash = new SplashScreen(5000, appLogo, "Text Editor", "Copyright (c) 2020", "John Doe");
splash.timer1.Enabled = true;
splash.ShowDialog();
splash.timer1.Start();
// Wait for Tick event to occur.....
splash.Close();
}
在 SplashScreen 表单中,您需要定义 Tick 事件:
timer1.Tick += new EventHandler(CloseForm);
这调用了一个关闭表单的方法:
private void CloseForm(Object source, EventArgs eventArgs)
{
this.Close();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.