470,619 Members | 1,469 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

Start timer when form loads

I want to start a timer when an object loads, so I put the code to start it
in the constructor. The problem I am having is that when I put the object
on a form in development it starts the timer. Is there a way to get this so
that it doesn't run unless the program has actually started?
Nov 21 '05 #1
4 1396
"Altman" <No******@SickOfSpam.com> schrieb:
I want to start a timer when an object loads, so I put the code to start it
in the constructor. The problem I am having is that when I put the object
on a form in development it starts the timer. Is there a way to get this
so that it doesn't run unless the program has actually started?


\\\
If Not Me.DesignMode Then
Me.Timer1.Enabled = True
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Herfried,

Are you sure of this answer (I did not test it) however it seems so strange
for me.
Is the answer not to set the timer1.enabled = true in the form.activated
event?

For me was confusing what is meant with "when an object loads", because I do
not understand what is meant by that and I could only think about a form by
that what was busy with painting etc.

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.at>
I want to start a timer when an object loads, so I put the code to start
it in the constructor. The problem I am having is that when I put the
object on a form in development it starts the timer. Is there a way to
get this so that it doesn't run unless the program has actually started?


\\\
If Not Me.DesignMode Then
Me.Timer1.Enabled = True
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
"Cor Ligthert" <no************@planet.nl> schrieb:
Are you sure of this answer (I did not test it) however it seems so
strange for me.
Is the answer not to set the timer1.enabled = true in the form.activated
event?


I assumed that the OP placed a timer on a usercontrol and wants to disable
the timer when the control is in design mode.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
This is correct the designmode thing works. I have a timer that is
refreshing some data with some external hardware and it kept trying to
communicate with it while I was trying to change some things in design mode.
I originally had all of this in a class and designmode is not a property of
a regular class so I made the control not make an instance of the class when
in design mode.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eu**************@TK2MSFTNGP14.phx.gbl...
"Cor Ligthert" <no************@planet.nl> schrieb:
Are you sure of this answer (I did not test it) however it seems so
strange for me.
Is the answer not to set the timer1.enabled = true in the form.activated
event?


I assumed that the OP placed a timer on a usercontrol and wants to disable
the timer when the control is in design mode.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by martin1 | last post: by
10 posts views Thread by Doug Robertson | last post: by
6 posts views Thread by =?Utf-8?B?QWxsZW4=?= | last post: by
7 posts views Thread by Smokey Grindle | last post: by
2 posts views Thread by =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post: by
12 posts views Thread by =?Utf-8?B?ZXAu?= | last post: by
2 posts views Thread by Andreas Hohn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.