1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| Public Class RepeatButton
Inherits System.Windows.Forms.Button
Public Sub New()
AddHandler timer.Tick, AddressOf OnTimer
timer.Enabled = False
End Sub
Public Timer As New timer
Public Property Interval() As Integer
Get
Return timer.Interval
End Get
Set(ByVal Value As Integer)
timer.Interval = Value
End Set
End Property
Private Sub OnTimer(ByVal sender As Object, ByVal e As EventArgs)
'fire off a click on each timer tick
OnClick(EventArgs.Empty)
End Sub
Private Sub RepeatButton_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
'turn on the timer
timer.Enabled = True
End Sub
Private Sub RepeatButton_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
' turn off the timer
timer.Enabled = False
End Sub
End Class |
Partager