custom control: combobox + timer

  • Thread starter Thread starter Bernie Yaeger
  • Start date Start date
B

Bernie Yaeger

I'm trying to create a custom control that contains both a combobox and a
timer. Any ideas how I can accomplish this? I do know how to create a 'one
control' inheritance control, but when I add the timer, it compiles but I
don't get its functionality - and it's not ticking, as I want it to.

Thanks for any help.

Bernie Yaeger
 
Hi Bernie

Here's an example called TimerComboBox. When you click on it, it adds items
to the list...

HTH

Nigel Armstrong

Public Class TimerComboBox
Inherits System.Windows.Forms.ComboBox

Private WithEvents mTimer As System.Windows.Forms.Timer
Private i As Integer = 0
Public Sub New()
MyBase.New()
mTimer = New System.Windows.Forms.Timer
mTimer.Interval = 1000

End Sub

Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
mTimer.Enabled = Not mTimer.Enabled
End Sub

Private Sub mTimer_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles mTimer.Tick
Me.Items.Add(i)
i += 1
End Sub


Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
mTimer.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
End Class
 
Back
Top