0% found this document useful (0 votes)
74 views

Form - Modal Property (System - Windows.Forms) - Microsoft Docs

The Form.Modal property gets a value indicating whether the form is displayed modally. It is a boolean property that returns true if the form is displayed modally, otherwise it returns false. The examples demonstrate checking the Modal property value and changing the form style if it is not modal. Modal forms prevent input to other forms until the modal form is closed. This property can determine if a form obtained elsewhere was displayed modally.

Uploaded by

John Smith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Form - Modal Property (System - Windows.Forms) - Microsoft Docs

The Form.Modal property gets a value indicating whether the form is displayed modally. It is a boolean property that returns true if the form is displayed modally, otherwise it returns false. The examples demonstrate checking the Modal property value and changing the form style if it is not modal. Modal forms prevent input to other forms until the modal form is closed. This property can determine if a form obtained elsewhere was displayed modally.

Uploaded by

John Smith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Form.

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

Gets a value indicating whether this form is displayed modally.

C# = Copy

[System.ComponentModel.Browsable(false)]
public bool Modal { get; }

Property Value
Boolean

true if the form is displayed modally; otherwise, false .

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

private void ShowMyNonModalForm()


{
Form myForm = new Form();
myForm.Text = "My Form";
myForm.SetBounds(10,10,200,200);

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.

To display a form modally use the ShowDialog method.

Applies to
Product Versions

.NET 5.0

.NET Core 3.0, 3.1

.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()

Is this page helpful?


 Yes  No
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.modal?view=net-5.0 2/3
2/19/2021 Form.Modal Property (System.Windows.Forms) | Microsoft Docs
 es  o

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.modal?view=net-5.0 3/3

You might also like