我想到的是:
Private Sub CreateTimer()
Dim tmr As New Timer
tmr.Interval = 1000 '1 Second
tmr.Enabled = True
AddHandler tmr.Tick, AddressOf GlobalTimerTick
End Sub
'A timer tick handler that would work for each timer I add with the sub above
'All timers I created should work seperately
Private Sub GlobalTimerTick(TheTimer as Timer, ByVal sender As Object, ByVal e As EventArgs)
mynumber = mynumber + 1
With DataGridView1
.Rows(n).Cells(4).Value = mynumber " saniye"
End With
End Sub
那我怎么能实现这个目标呢?
答案 0 :(得分:2)
我相信Timer的Tag
属性可以很好地适用于你的情况。我目前没有我的IDE,但下面的代码片段可以给你这个想法。
Private Sub CreateTimer()
Dim tmr As New Timer
tmr.Interval = 1000 '1 Second
tmr.Enabled = True
tmr.Tag = ROW_INDEX
AddHandler tmr.Tick, AddressOf GlobalTimerTick
End Sub
'A timer tick handler that would work for each timer I add with the sub above
'All timers I created should work seperately
Private Sub GlobalTimerTick(ByVal sender As Object, ByVal e As EventArgs)
mynumber = sender.Tag
With DataGridView1
.Rows(n).Cells(4).Value = mynumber " saniye"
End With
End Sub