Search

Saturday, September 28, 2013
0 comments

Difference between Application.Run() and form.showDialog() method in windows form

10:13 AMSaturday, September 28, 2013
class program {
  static void Main() {
    Form form = new Form();
    form.ShowDialog();
  }
}

This code would show a blank form and wait for the user to close it before returning control to the Main function, but it's not the code you will generally be writing. Instead, to make it accessible in other parts of your application, you'll be designating one form as the main form. To do this, pass the main form as an argument to the Run method of the Application object, which also resides in the System.Windows.Forms namespace

class program {
  static void Main() {
    Form form = new Form();
    Application.Run(form);
  }
}

The Application class's static Run method will show the main form, and when it's closed, Run will return, letting our Main function exit and closing the process.


Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top