Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between modal and non-modal forms in c#?

Tags:

c#

winforms

What does it mean that a windows forms is modal or not? I can't find the difference anywhere on the internet. I have allready tried looking it up on the internet, here in stack overflow, around the microsoft forums, other computing science formus, reddit,etc. and i yet have to find a page where the difference is clearly explained. I know it's probably a stupid question but i feel like i have to know the answer to it.

like image 351
Biel Gonzalez Pibernat Avatar asked Nov 01 '25 07:11

Biel Gonzalez Pibernat


2 Answers

Modal in the context of UI design, means that an element will be visible on-top of its parent, while disabling it. The idea is that the modal element will capture the input instead of its parent. A modal element, changes the mode of interaction.

From the documentation on Form.Modal:

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.

See Modal Window at Wikipedia:

In user interface design for computer applications, a modal window is a graphical control element subordinate to an application's main window. It creates a mode that disables the main window but keeps it visible, with the modal window as a child window in front of it. Users must interact with the modal window before they can return to the parent application.

From the paper Multimodal Human Computer Interaction: A Survey we get a definition of modality:

We use a human-centered approach in our definition: by modality we mean mode of communication according to human senses or type of computer input devices

See also the paper Human-Computer Interaction: Overview on State of the Art. And the question What is modal about a modal dialog? at the User Experience sister site.

like image 59
Theraot Avatar answered Nov 03 '25 23:11

Theraot


Although you will probably get more, and the links and comments provided by Theraot are very good, I will throw in something that might clarify.

A message box asking you a "do you want to do …?" with a yes/no/cancel. You can't do anything else until that dialog window is done. All other windows prior to the current are in a wait until this yes/no/cancel dialog is finished, then continue operation.

Now, that is an over-simplification of it. A modal dialog could be an entire form with many buttons, controls. The purpose is that you need all these "things" filled in / done before whatever the next step is within your application needs.

From a non-web based concept, but similar would also be applicable. You have a product/service to sell. Someone places an order or service request. Before you can complete an order, you need all the customer's information. So you would create a window with things like name, address, etc that are critical to continue, even if the bare minimum is a name and phone for contact purposes. The "Save" button on the form would make sure minimum components required and saves the record for the customer and returns. NOW you can complete the rest of the order and assign to the new customer.

Also, if dealing with a bank transaction, you have a transaction. You need to enter all the + from this account and - to other account, make sure all + balance the - before you save.

Note, you could have nested modal windows, but each modal window has to be completed before control returns back to the previous. So, lets take the first example. You have a new customer. You call a modal window to get the customer's information. Within the this modal form, there is some other set of information associated with a customer that just doesn't fit well on the add customer screen, so a button on this screen calls a secondary modal form to get some additional context. Now that form is the top-most for operations. When it is completed, it returns back to the add customer screen. When done with add customer screen, you get back to the rest of normal operations.

Hopefully this helps in the context of how a modal window can be used. In summary its just a do all on this form first before you return and resume operations after. If no customer is ever added, you would not want to complete a given order or service call.

like image 38
DRapp Avatar answered Nov 03 '25 22:11

DRapp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!