Question Controlling a timer from outside class.

JDTrakal

New member
Joined
Oct 28, 2010
Messages
3
Programming Experience
Beginner
I was wondering if anyone can help me with this query for my current Uni assignment.

We've been asked to make a program based on a spec where we enter some details and it will then output a graph. Part of the assignment asks us to set up a timer so that the bar chart will display each bar seperately with a time delay between each one. However the timer is assigned to a form (Form2) while the draw commands are within another class called Expenditure.

While the specification doesn't specifically say we should stop the timer from within the class it is implied.

Now I have tried Form2.Timer1.Stop() and Form2.Timer1.Enabled = False within the class without any luck.

I'm wondering is it possible for the Expenditure class to stop the timer or does it need to be done within Form2?

Many thanks.
 
Raising events or sending references between the two classes are two options. Can you elaborate on why the timer is "assigned" to Form2? It seems it should be in the Expenditure class along with the draw commands since it is controlling the timing of the draw commands.

Should you decide to keep the timer in Form2, here is an article showing several methods of passing "values" between forms: Passing Values Between Forms in .NET
Since Forms are classes, the methods shown should be applicable.
 
Back
Top