By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Add a Timer to a form at run time

P: n/a
Hi

I must be missing some obvious point, but can someone let me know how do I add a windows.forms.timer control to a form at run time

Private TM as new windows.forms.time
Dim sForm as for

sForm.controls.add(TM)
=> throwing an error - Value of type 'System.Windows.Forms.Timer' cannot be converted to 'System.Windows.Forms.Control'

Basically I have a progress bar in this form which I want to update under a Timer control. I can access this progress bar using sForm.Controls but unable to get a handle on this timer component.

Regard

Vina

Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Cor
Hi vinay,
\\\
dim withevents mytimer as windows.forms.timer
mytimer.enabled = true
////

I hope this helps,

Cor

I must be missing some obvious point, but can someone let me know how do I add a windows.forms.timer control to a form at run time.
Private TM as new windows.forms.timer
Dim sForm as form

sForm.controls.add(TM)
=> throwing an error - Value of type 'System.Windows.Forms.Timer' cannot be converted to 'System.Windows.Forms.Control'.
Basically I have a progress bar in this form which I want to update under a Timer control. I can access this progress bar using sForm.Controls but
unable to get a handle on this timer component.
Regards

Vinay

Nov 20 '05 #2

P: n/a
To add to what Cor has already posted....

You can't add a timer into a form because it isn't a control, as the error
stated..
however there's no need to add it to the form to use it..

Just declare it as in Cor's earlier reply.

You will also need to Add a Handler for the Tick event
and Start the Timer

as in

// Code //
Private SomeCode Sub
Dim timer as New windows.forms.timer
AddHandler timer.Tick, Addressof MyTimerHandlersSub
timer.start
End Sub

Private Sub MyTimerHandlersSub(ByVal sender As System.Object, ByVal e As
System.EventArgs)

' Do Something Usefull in Here....!!!! like update your progress bar....

End Sub

//End Code//

HTH
Rigga.

"vinay" <cu****@cursor.com> wrote in message
news:31**********************************@microsof t.com...
Hi,

I must be missing some obvious point, but can someone let me know how do I add a windows.forms.timer control to a form at run time.
Private TM as new windows.forms.timer
Dim sForm as form

sForm.controls.add(TM)
=> throwing an error - Value of type 'System.Windows.Forms.Timer' cannot be converted to 'System.Windows.Forms.Control'.
Basically I have a progress bar in this form which I want to update under a Timer control. I can access this progress bar using sForm.Controls but
unable to get a handle on this timer component.
Regards

Vinay

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.