How do you make a non-modal topmost dialog that is only topmost in regards to the parent form in WinForms?

StackOverflow https://stackoverflow.com/questions/675105

Question

Thinking about this for an About dialog but I'm sure it's applicable in other places (say a find box)

Sorry if this is a dupe, but I couldn't find this or how to articulate the last part about it only being on top of the parent. How do you make a form that is always on top of the parent form, but is non-modal, but doesn't cover up other apps?

Was it helpful?

Solution

Try this to open your dialog:

FindDialog fd = new FindDialog();
fd.Show(this);

The key is to assign dialog's owner.

OTHER TIPS

Not sure exactly what you mean; Form.ShowDialog is only modal with respect to the parent, not the application, unless the application is single threaded.

For example, I made an app to test this which was organized like the following:

mainform: 2 buttons, each of which begins a thread that creates a frmDialog1 and calls ShowDialog

frmDialog1: single button which creates a frmDialog2 and calls ShowDialog on it.

frmDialog2: does nothing (ie. blank)

when they were all running I could access/drag mainform. I could also do the same with frmDialog1 (both versions) only if I hadn't clicked the button that shows dialog 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top