private void btnClose_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("¿Esta seguro que desea Salir?", "Salir", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { FormularioAcesso formularioAcesso = new FormularioAcesso(); formularioAcesso.Show(); this.Close(); } }
public frmPrincipal() { InitializeComponent(); bool open = false; FormularioAcesso formulario = new FormularioAcesso(); foreach (Form frm in Application.OpenForms) { if (frm.GetType() == typeof(FormularioAcesso)) { open = true; MessageBox.Show("El formulario ya esta abierto"); break; } } if (!open) { formulario.MdiParent = this; formulario.Show(); } }