David Ly
David Ly

Reputation: 31606

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

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?

Upvotes: 2

Views: 8125

Answers (2)

Steven Evers
Steven Evers

Reputation: 17216

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.

Upvotes: 0

Jay Riggs
Jay Riggs

Reputation: 53603

Try this to open your dialog:

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

The key is to assign dialog's owner.

Upvotes: 8

Related Questions