Start timer when form loads

  • Thread starter Thread starter Altman
  • Start date Start date
A

Altman

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?
 
Altman said:
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
///
 
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
 
Cor Ligthert said:
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top