我有一个像记分牌倒数计时器一样运行的计时器。有没有办法可以将相同的计时器显示为两个窗口形式(winforms),而无需借助属性?
答案 0 :(得分:1)
尝试在其他表单的构造函数中传递对计时器的引用,并添加自己的tick事件处理程序:
Public Class Form2
Public Sub New(ByVal mainTimer As Timer)
InitializeComponent()
AddHandler mainTimer.Tick, AddressOf mainTimer_Tick
End Sub
Private Sub mainTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)
'// do something
End Sub
End Class