使用计时器控件打开表格 [英] Opening Form using Timer Control

查看:93
本文介绍了使用计时器控件打开表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当系统手表读取在数据库中输入的指定时间并且在任务栏中将项目最小化时,我想打开一个新表单.

任何帮助将不胜感激...

谢谢
Sangaur

Hi
I want to open a new form when my system watch reads the specified time entered in my data base and my project is minimised in taskbar.

Any kind of help will be highly appreciated...

Thanks
Sangaur

推荐答案

您可以使用计时器控件"和窗口窗体"的属性来实现此目的
看到此代码:
You can achive this by using Timer Control and Properties of Window Form
See this code :
'Declare one Private Varialbe 
Private _TimeLimit As Integer = 0
'Ad this code on Form Load Event
Private Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Form1.Load
    Timer1.Enabled = True
    Timer1.Interval = 100
    Timer1.Start()
End Sub
'Add this code on Timer Tick Event
 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        _TileLimit = _TimeLimit + 1  'Increasing value of _TimeLimit b 1
        If _TimeLimit = 100 Then WindowState = Minimized
        'When _TimeLimit Value is 100 Form gets Minimized.
 End Sub


我在这里获取时间变量,您可以使用Ado.Net从数据库中读取时间
希望对您有帮助. :)


Here i am taking variable for time you can read time from your DataBase using Ado.Net
I hope it will help you. :)


Private Sub tmrSplash_Timer()

tmrSplash.Enabled = False
frmMain.Show
Unload Me

End Sub


设置计时器一个合适的时间间隔-根据您需要的精度,将其设置为大约一半.因此,您需要在所需时间的一分钟内将其打开,将时间间隔设置为30秒(或在Interval属性中为30000.).
设置一个Tick事件处理程序.
启动计时器.
发生滴答事件时,请使用DateTime.Now查看是否该显示新表单了.如果没有,请忽略它.
时间到了,停止计时器,构造新表单,并在新实例上使用Show方法.
Set up a timer with a suitable interval - depending on the accuracy you need, set it to about half that. So it you need it opened within a minute of the time you require, set the interval to 30 seconds (or 30000 in the Interval property.
Set a Tick event handler.
Start the timer.
When the tick event occurs, use DateTime.Now to see if it is time to display your new form. If not, ignore it.
When it is time, stop the timer, construct your new form, and use the Show method on the new instance.


这篇关于使用计时器控件打开表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆