winforms - C#: How to prevent main form from showing too early -


In my main method, I start primarily as usual:

  Application EnableVisualStyles (); Application.SetCompatibleTextRenderingDefault (wrong); application. Play (New Mainform ());  

I have the following for loading in main forms, which will prompt the user for logging and stuff.

 using  (loginForm) {DialogResult r = LoginForm.ShowDialog (); Switch (R) {Case DialogResult.OK: Break; Default: application.Exit (); Return; }}  

My problem is that the main appearance is seen in the background, and I want it, okay ... no. Unless login is okay. How should I do this? Application.Ran () method says that it automatically shows the form. Is it an alternative way to start the main form without showing it? Or will I have to set up the main character in the constructor to show the liars, and then when the log is done, or something like that? What is the recommended way to do this? Entry forms are intended as joint splash screens and logins. So first it loads and sets some different things, and then asks the user to login.

instead of:

  Application Play (New Mainform ());  

Try:

  log in login // login login client = new login dialog (); If (login.ShowDialog () == DialogResult.OK) {// check credentials // if the credentials apply fine.Ran (new mainform ()); }   

ShowDialog method is a blocked call, unless the dialog is stopped in response to user input - Pressing the OK button or the program will stop ' Cancel 'button.


Comments