473,569 Members | 2,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add a Timer to a form at run time

Hi

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

Private TM as new windows.forms.t ime
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
2 10417
Cor
Hi vinay,
\\\
dim withevents mytimer as windows.forms.t imer
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.t imer control to a form at run time.
Private TM as new windows.forms.t imer
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
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.t imer
AddHandler timer.Tick, Addressof MyTimerHandlers Sub
timer.start
End Sub

Private Sub MyTimerHandlers Sub(ByVal sender As System.Object, ByVal e As
System.EventArg s)

' 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******** *************** ***********@mic rosoft.com...
Hi,

I must be missing some obvious point, but can someone let me know how do I add a windows.forms.t imer control to a form at run time.
Private TM as new windows.forms.t imer
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
7460
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the...
9
7256
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null; Let's declare a constant Int32 m_TimePeriod = 10000;
4
3322
by: Dan | last post by:
Hi, I have a timer on a form (System.Windows.Forms.Timer - Framework 1.1) that is set to 60 seconds as sort an of inactivity monitor. If 60 seconds have elapsed without any user activity I want the form to close. I stop/start the timer at button clicks and keydown events etc of the various controls on the form. Users have reported the...
10
27660
by: Vincent | last post by:
Hi, I was trying to do something in a Thread that starts by a timer. I turn off the timer at the begining of the thread incase it fires again when the thread is still running. Then turn on the timer again before the thread finishes. To my surprise, the timer never come alive again once it has been turned of in the thread. To test the...
7
2663
by: Mike Eaton | last post by:
Hi All, I have a simple application that allows users to clock in and out and stores the data for use by the payroll department. It spends most of its life as a tray icon and when the user clicks on it, a clock-in/out form is displayed. My problem is this: I've added a timer to the main module to allow the user to set a time to be...
8
2470
by: Xero | last post by:
Hello. Could anybody suggest a way to create a timer? I want to timer to be displayed to the user, telling he or she how much time has passed. Thanks. -- Xero
4
11098
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts the default of True. The Elapsed event handler updates the dialog box with how long before it will close, acting as a timer itself. The dialog has a...
4
4623
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this program is like so: static void Main() {
11
2584
by: Hotrod2000 | last post by:
I'm quite new to programming but I'm having problems getting a timer to work in visual studio.net I've created a timer on a form, enabled it and then typed the following code (from the mdsn library as I thought this would be a good start!!!) but nothing happens :- Imports System.Timers
0
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.