Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body!

I have a question about timer

How to stop a timer in other form. for example i'm in form2 and there is a timer in form3 and its working
and i wanna stop it, so what should i do?

Give me a hand please i should add im not a pro programmer please tell me the answer in simple way!

thanks
Posted
Updated 12-Jan-12 11:41am
v2
Comments
Catalin Serafimescu 12-Jan-12 16:34pm    
This involves that forms knows one about another. It's not a good technique, you should review your design.

It looks like your problem is about "in other form". The simplest solution is obvious: you need to have an internal method in one form and one form instance should have a reference to another form instance. This is not elegant though as a form can get more access than it's really required.

This is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class and passing the interface reference instead of reference to a "whole instance" of a Form. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

—SA
 
Share this answer
 
Comments
i.fakhari 12-Jan-12 16:59pm    
yes i have a problem with forms but i know how to solve the question that you showed me because its about public x and its not exactly what i asked because that i wanted to change a property and change s.t and i dont want to read anything...
i think the i can solve the problem if i could access to the timer in each for and make it public !? so how can i do it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900