Click here to Skip to main content
16,011,804 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on a project in VB.net 2008. I have a problem arising while opening a form as modal from a modeless form. I have attached a project to demonstrate the problem. This demonstration contains three forms with following characteristics.

- "Form1" is main form of the demo application and

- "Form2" is opened as modeless form through "Form1". It is hidden (using me.hide() method) instead of closing and Cancel the closing in closing event of "Form2".

- "Form3" is opened as modal form through "Form2".

Now problem is when I hide "Form2" after closing "Form3", "Form1" also hides in the background (when some other windows are also open i.e. Windows explorer). I am unable to find a reason for this behavior. This should looks like a common problem and must be encountered by someone else but I am unable to find it on internet. So please help as I need reason and solution for this problem.

Regards,

Hassan
Posted

1 solution

Insert this before hiding form2:

Owner.Focus()

This will give the owner (form 1) the focus and may change this behavior when form 2 is hidden.
 
Share this answer
 

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