Timer values doesn't works after close and open the form

saba

Member
Joined
Jun 5, 2021
Messages
6
Programming Experience
1-3
In timer event I'm passing some values in textbox in child form ,when I close the child form and open again ,the timer is running but the textbox not displaying the values,but if I doesn't change the form ,the timer works correctly , do I need to initialize the timer in form load ?
 
I have deleted your previous second and third posts. The second one contained a ridiculous amount of code and then, to make matters worse, the third one quoted all that code. Please use a bit of common sense. Post ONLY the code relevant to the problem. That certainly does include all the designer code and almost certainly doesn't include all the user code either. Also, when posting code snippets, use the formatting tools provided to format it as code. Among other things, that will retain indenting, making the code easier to read, and it will also provide a box with a scrollbar, making necessarily long code snippets easier to manage.
 
My guess is that your timer event code is referencing a textbox that belonged to the old form and not the new form, but without seeing the relevant code, this would be hard to confirm.

In general, the fact that the timer knows about the textbox inside of a form is already a strong code smell that the encapsulation rules of good object oriented design is being broken. The correct approach is to hookup an event between the timer and the form, and for the form to update the textbox itself with the appropriate data.
 
Back
Top Bottom