MDI form and Child form Focus Problem
-
Hello All, Happy New Year. I am developing an application in vb.net 3.5 I have a MDI form and Several Child Form. In my MDI form I put some Button Like Save,Exit ... In these button Click Event I called the Save function or exit function of the Child Forms. Suppose I have Two Child Form "Form1" and "Form2" In the MDI Save Button Click I call the different events different "Form1.Save" or "Form2.Save". But There is a Focus problem In my Child forms. If I am go for "Form1.Save" its working, but after save the focus will be return back to the "Form1", Then If I doing any activity in my "Child1" it throws an error message "Object reference not set to an instance of the object..." and also a strange problem occures in my form after these any event will be called twice. So, What is the Solution of this problem. Please Help me.
Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)
-
Hello All, Happy New Year. I am developing an application in vb.net 3.5 I have a MDI form and Several Child Form. In my MDI form I put some Button Like Save,Exit ... In these button Click Event I called the Save function or exit function of the Child Forms. Suppose I have Two Child Form "Form1" and "Form2" In the MDI Save Button Click I call the different events different "Form1.Save" or "Form2.Save". But There is a Focus problem In my Child forms. If I am go for "Form1.Save" its working, but after save the focus will be return back to the "Form1", Then If I doing any activity in my "Child1" it throws an error message "Object reference not set to an instance of the object..." and also a strange problem occures in my form after these any event will be called twice. So, What is the Solution of this problem. Please Help me.
Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)
pdnet wrote:
If I am go for "Form1.Save" its working, but after save the focus will be return back to the "Form1",
So the focus is staying in the form that was active? Or do you mean that if you're on form2 and you press save for form1 the focus goes to form1. If that's the case, you most likely set the focus during the save.
pdnet wrote:
hen If I doing any activity in my "Child1" it throws an error message "Object reference not set to an instance of the object..."
Didn't quite get what was child1 but I'd guess you store a reference to your form somewhere which is at call time nonexistent.
pdnet wrote:
also a strange problem occures in my form after these any event will be called twice
Most likely you have duplicate handlers for those events.
The need to optimize rises from a bad design.My articles[^]