Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShowDialog() doesn't make the window modal

Tags:

c#

winforms

I have a windows form that pops up a dialog box if certian conditions are met when the form loads. The problem is the window does not stay on top and I can still click thing on the parent. However, there is a button on the form that when pressed opens the same window, when I do this it works as expected (like a dialog window).

Is there an issue with showing a dialog when a form is first loading?

like image 604
DaBomb Avatar asked May 29 '09 15:05

DaBomb


1 Answers

Are you calling ShowDialog from the Form class? Because it will only set the parent window if called from another Form. Alternatively you can use the overload that has the IWin32Window parameter to specifically set the owner.

like image 129
Tom van Enckevort Avatar answered Sep 28 '22 07:09

Tom van Enckevort