Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do a make one form stay on top of another?

Tags:

c#

winforms

I have found the Form.TopMost property but it puts the form on top of everything, including stuff that isn't part of my app. I've got a suspicion that I'm missing something obvious here. (Is Form the proper bases class for a non modal dialog box?)

like image 608
BCS Avatar asked Jul 13 '09 18:07

BCS


People also ask

How do you keep a form on top?

You can bring a Form on top of application by simply setting the Form. topmost form property to true will force the form to the top layer of the screen, while leaving the user able to enter data in the forms below. Topmost forms are always displayed at the highest point in the z-order of the windows on the desktop.

How to bring form front c#?

When the user has the program minimized and presses F3 a global hook keys gets the press and translation window should be made and brought to front.


2 Answers

Use the Form.Owner property of your dialog form and set it to the main Form.

Read more here http://msdn.microsoft.com/en-us/library/system.windows.forms.form.owner.aspx

The Owned form will never be displayed behind the Owner Form.

like image 86
CodeFusionMobile Avatar answered Oct 10 '22 04:10

CodeFusionMobile


It is very simple; You just have to pass the owner when you call the Show() method

YourForm.Show(parentForm);
like image 24
Ahmed Yossef Avatar answered Oct 10 '22 02:10

Ahmed Yossef