I am making my main form call another form programatically.
But I am noticing that the focus goes briefly to that form then goes right back to the main form.
How can I get the call form to have the focus instead of the main?
I don't make forms modal if possible, could you tell us where you are calling the new form from? Throughout my multiuser applications I call forms from forms.
Hey Wbstrider, I call the second form by issuing this:
this.cmdOpen.click in the Activate method of the main form which has this command button 'cmdOpen'
There is something in your code/properties in one or other form to create this behaviour.
To test normal form behaviour, create a new form from the form class and call it Form1. Add a cmdButton, with DO FORM form2 in the click event. DO not change any other properties.
Create a new form from the form class and call it form2. DO not change any other properties.
Run form1 and click on the cmdButton. You will then be able to click and getfocus on either form.
Apart from the cmdButton.Click() event, there is no code in either form, and the behaviour is as one would expect.
You will need to examine all the properties and events of both your problem forms.
Make copies and if you then right click on the "All" tab on the properties sheet in each form and select "Non default", you will see all the non default properties and methods. I would then start setting them back to default/testing etc until you find the problem.
If you put a form call in the activate event, the activate event will finish by activating itself. So yes, your second form gets the focus, but when the activate event is finished focus will turn to your frst form again.
What you can do is disable the first form as long as you second form is active by setting the enabled property of your first form to .F.
As soon as the second form is destroyed, enable the first form.
This construction works very fin when you use formsets, in which you would use the formset as a sort of mediator design pattern, where the forms are not aware of each others existence, and everything is handled(mediated) by the formset.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.