I have a main form, which opens form A, where from form A I can open form B, where from form B I can open form C. The problem is that if I open till form B, everything works fine, but if I open form C as well, and then close Form C and B, form A goes behind the main form. For the forms I m just creating an instance of the form and then use .Show()
cNewForm form = new cNewForm();
form.Show();
I m doing this for every form
You have not set the window ownership properly because you are using the no parameter version of
Show(). You need to set the owner by calling theShow()overload that receives an owner parameter. Alternatively you can set theOwnerproperty directly, but it’s much better to do so when you callShow().The window owner is an important Win32 concept. I recommend reading the MSDN documentation on the subject.
In your case I think you want form A to be owned by your main form, and form B to be owned by form A, and form C to be owned by form B.