private void sairToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); SegurancaForm f = Application.OpenForms["SegurancaForm"] as SegurancaForm; f.Show(); }
private void PrincipalForm_FormClosing(object sender, FormClosingEventArgs e) { DialogResult dg; using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { dg = MessageBox.Show(this, "Tem certeza que deseja sair?", "Encerrar programa", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (dg == DialogResult.No) { e.Cancel = true; } else { SegurancaForm f = Application.OpenForms["SegurancaForm"] as SegurancaForm; f.Close(); } }