What's the difference between Show(), ShowDialog() and Application.Run() functions? [duplicate]
What's the difference between new Show(), ShowDialog() and Application.Run() functions?
In main
(winforms) I saw :
Application.Run(new Form1());
Then, for Form1, I also saw Form1.Show()
with description: "Shows the control to the user."
For ShowDialog, it said "Shows the form as a modal dialog box".
What does this mean?
What are each of their uses and which is most common?
Solution 1:
The Show
function shows the form in a non modal form. This means that you can click on the parent form.
ShowDialog
shows the form modally, meaning you cannot go to the parent form
Application.Run()
runs the main parent form, and makes that form the main form. Application.Run() is usually found in main
.
Solution 2:
-
Show
displays the form in a non-modal way. -
ShowDialog
displays the form in a modal way. -
Application.Run
starts a message loop for the application and shows the form as the application's main form