I don't understand why this property doesn't have a setter. What would happen if you were able to set this property?
-
Are you looking for [`Form.ShowDialog()`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.showdialog)? – 41686d6564 stands w. Palestine Jun 14 '18 at 05:20
-
Why the downvotes? – Amen Jlili Jun 14 '18 at 23:29
-
@AhmedAbdelhameed I'm not looking for that method I was wondering it was possible to change the modal state of a form after it was shown. – Amen Jlili Jun 14 '18 at 23:34
-
1No, that's not possible as explained in the answers below. As I mentioned in my answer, if you need to understand exactly why, read [Hans Passant's answer](https://stackoverflow.com/a/5183623/4934172) to the linked question in order to know how `ShowDialog()` accomplishes that. – 41686d6564 stands w. Palestine Jun 14 '18 at 23:38
-
Thanks i dont understand why my question is downvoted.... – Amen Jlili Jun 15 '18 at 00:07
3 Answers
As others have said, it depends on how the form is currently being used, I.e. whether it was Show()
ed or ShowDialog()
ed. Whilst the form is being shown, it doesn't make sense to allow you to change it's modality1.
When the form isn't being shown, it also doesn't make sense to have this be a settable property since what matters is whether the next use of the form is via Show
or ShowDialog
.
Whilst it's true that most forms will only ever be shown either modally or non-modally, the option remains open to use a single form in both manners.
1Especially because when a form is being shown modally via ShowDialog
, the code calling ShowDialog
is blocked until it returns with the result of the dialog. If you were to change a form to be modal after it was already Show
n, there's nobody waiting to receive the dialog result when it returns.

- 234,701
- 27
- 340
- 448
The purpose of Form.Modal
property, from the documentation:
Gets a value indicating whether this form is displayed modally.
So, it only checks for the modal status of the form. It doesn't make sense for it to have a setter.
In order to open a form modally, you should use the ShowDialog()
method, also as explained in the link above. That way when you check for the Modal
property, it returns true.
If your question is whether or not you can have a modal form after it's been shown, the answer is no, you can't. To understand why, you need to know how ShowDialog()
makes the form modal in the first place. Check this awesome answer by Hans Passant in order to understand how ShowDialog()
works at a technical level.

- 19,168
- 12
- 41
- 79
I don't understand why this property doesn't have a setter. What would happen if you were able to set this property?
It doesn't have a setter because you cant change its Modal style once the Form has been shown. Although subtle, Modal and and Non Modal forms behave differently in regards to owner, and blocking the caller, and other less obvious things. It seemingly just not worth the confusion of adding this i would imagine.
Further more, users must interact with the Modal/Dialog window before they can return to the parent application. This avoids interrupting the workflow on the main window and by design.
So if you want a Modal Form, call ShowDialog()
or else call Show()

- 79,002
- 9
- 103
- 141