Topmost property


Mar 2, 2005
Programming Experience

I know how the Topmost property works (keeps a form on the foreground), but is it possible to make a form topmost, only within the program itself..
It should disappear when opening an other application, but now it always stays on top, even when opening an other app...

Anyons knows how to solve this?
You can try setting the Owner property of the form that you want on top of the application. Try that and see if it's what you're after.
An owned for behaves like the Find and Replace box in VS. It is always on top of the app's main window while still allowing you to access that main window, unlike a modal dialog, but will fall down the z-order with that main window as other apps are activated. This could be thought of as TopMost in the context of the application but not for the whole desktop.
Own solution

We have found another solution, and it's a really easy one..

Instead of using

we discovered that Form.showDialog() does the thing that we wanted to do it :s

Extremely idiot, but it works :eek:
To clarify a few things for those having similar issues:

  • Setting the TopMost property to True causes a form to be shown on top of all other (non-TopMost) windows, even when it does not have focus, without preventing access to other windows. This is the default behaviour of the Windows Task Manager.
  • Setting the Owner property causes a form to be shown on top of its owner at all times without prevening access to the owner. This is the behaviour of the VS Find and Replace window.
  • Using ShowDialog() to display a form creates a modal dialog, which prevents access to the calling form until it is closed. This is the behaviour of a MessageBox.

Latest posts