C # Close Windows login form

Source: Internet
Author: User
To close the logon form and open a new main form after the login form verification is complete. The principle is: create a new form before closing and save it in a form variable. Solution 2 is as follows:

Namespace inventory management
{
Static class Program
{
/// <Summary>
/// ApplicationProgram.
/// </Summary>

// Solution 2
Public static form FRM = NULL; // Save the variable of the new form after verification
Public static string username = ""; // Save the logon username and pass it to the new form.

[Stathread]
Static void main ()
{
Application. enablevisualstyles ();
Application. setcompatibletextrenderingdefault (false );

// Solution 1
// Note: after the verification is successful in the login form, execute:
// This. dialogresult = dialogresult. OK

// Login lg = New Login ();
// LG. showdialog ();

// If (lg. dialogresult = dialogresult. OK) application. Run (New form1 ());

// Solution 2
// Note: after the verification is successful in the login form, execute:
// Program. FRM = new form1 (); program. Username = logon username; this. Close ();
Application. Run (New login ());
If (FRM! = NULL) application. Run (FRM );
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.