public frmLogin(){ this .InitializeComponent() ; this .DialogResult = DialogResult.Cancel ;}private void OnLoginClick(object sender, EventArgs e){ //... //...any code... //... if (this .txtUser.Text == "Admin" && this .txtPass.Text == "123" ) { this .DialogResult = DialogResult.OK ; this .Close() ; }}
[STAThread]static void Main(){ Application.EnableVisualStyles() ; Application.SetCompatibleTextRenderingDefault(false ) ; using (var f = new frmLogin() ) { if (f.ShowDialog() != DialogResult.OK) return ; } Application.Run(new frmMain()) ;}