private void btLogin_Click(object sender, EventArgs e) { try { int n = cbStatus.SelectedIndex; switch (n) { case 0: MessageBox.Show("Pilih status akun Anda.", "Login"); break; case 1: this.Hide(); FRM_LOGIN FRM_LOGIN = new FRM_LOGIN(); FRM_LOGIN.Closed += (s, args) => this.Close(); FRM_LOGIN.ShowDialog(); break; case 2: this.Hide(); FORM_LOGIN_PENAMAS FORM_LOGIN_PENAMAS = new FORM_LOGIN_PENAMAS(); FORM_LOGIN_PENAMAS.Closed += (s, args) => this.Close(); FORM_LOGIN_PENAMAS.ShowDialog(); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected override void OnFormClosing(FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { DialogResult result = MessageBox.Show("Apakah anda yakin ingin keluar?", "Keluar", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { this.Hide(); var FRM_LOGIN = new FRM_LOGIN(); FRM_LOGIN.ShowDialog(); } else { e.Cancel = true; } } else { e.Cancel = true; } }