Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if a form is shown as dialog

Tags:

c#

winforms

Is there is already some property that I could use such as:

if (this.IsDialog)
{
    DialogResult = ...;
}
else
{
    //do something else
}

Or should I create such property myself and set it to true before showing the form as dialog?

like image 888
Dil Avatar asked Jun 19 '12 16:06

Dil


People also ask

What is the difference between show and ShowDialog methods in displaying a form?

Show() method shows a windows form in a non-modal state. ShowDialog() method shows a window in a modal state and stops execution of the calling context until a result is returned from the windows form open by the method.

What is ShowDialog C#?

ShowDialog() Shows the form as a modal dialog box. ShowDialog(IWin32Window) Shows the form as a modal dialog box with the specified owner.


1 Answers

You can check to see if this.Modal is true.

like image 173
Reed Copsey Avatar answered Sep 20 '22 14:09

Reed Copsey