Form - Modal Property (System - Windows.Forms) - Microsoft Docs
Form - Modal Property (System - Windows.Forms) - Microsoft Docs
Modal Property
2/19/2021 Form.Modal Property (System.Windows.Forms) | Microsoft Docs
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms.dll
In this article
Definition
Examples
Remarks
Applies to
See also
C# = Copy
[System.ComponentModel.Browsable(false)]
public bool Modal { get; }
Property Value
Boolean
Attributes BrowsableAttribute
Examples
The following example uses the Modal property to determine if a form is displayed as a
modal form. If it is not the FormBorderStyle and TopLevel properties are changed to make
the form a non-top-level form with a tool window border.
C# = Copy
myForm Show();
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.modal?view=net-5.0 1/3
2/19/2021 Form.Modal Property (System.Windows.Forms) | Microsoft Docs
myForm.Show();
// Determine if the form is modal.
if(myForm.Modal == false)
{
// Change borderstyle and make it not a top level window.
myForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
myForm.TopLevel = false;
}
}
Remarks
When a form is displayed modally, no input (keyboard or mouse click) can occur except to
objects on the modal form. The program must hide or close a modal form (usually in
response to some user action) before input to another form can occur. Forms that are
displayed modally are typically used as dialog boxes in an application.
You can use this property to determine whether a form that you have obtained from a
method or property has been displayed modally.
Applies to
Product Versions
.NET 5.0
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
See also
ShowDialog()
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.modal?view=net-5.0 3/3