A window always on top of another window

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

Hi all,

Say that I have two windows A and B. When I click a button
on window B, window A will pop up. I want A to be always
on top of B so that user cannot click and fire any buttons
(or any other controls) on Window B as long as Window A
appears.

I cannot use TopMost property because after Form A pops
up, I want another window to be always on top of
Form A (at the sametime I also want Form A to be always on
top of Form B).

(top)
Another Form (always on top of A)
|
Form A (always on top of B)
|
Form B
(bottom)

That's why if I use TopMost, I can't get the above to work.
I tried setting
A.Owner = B
but still I can click and fire any button(or controls) on
Form B.

Any help would be greatly appreciated.
Thank you in advance.


regards,
Sean
 
To get this kind of behaviour you want to open your forms modally.
e.g.
form formA = new form();
FormA.ShowDialog();

Obviously you would open formB in formA's implementation, and so on.

Br,

Mark.
 
Try setting form A's owner property to form B.

To make a form owned by another form, assign its Owner property a reference to the form that will be the owner.
When a form is owned by another form, it is minimized and closed with the owner form. For example, if Form2 is owned by form Form1, if Form1 is closed or minimized, Form2 is also closed or minimized. Owned forms are also never displayed behind their owner form. You can use owned forms for windows such as find and replace windows, which should not disappear when the owner form is selected. To determine the forms that are owned by a parent form, use the OwnedForms property.
 
Back
Top