private void dgvDados_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { foreach (Form openForm in Application.OpenForms) { if (openForm is FrmEmprestimo) { openForm.Close(); } } int ID_Emprestimo = int.Parse(dgvDados.CurrentRow.Cells[0].Value.ToString()); int ID_Usuario = int.Parse(dgvDados.CurrentRow.Cells[1].Value.ToString()); FrmEmprestimo frmEmprestimo = new FrmEmprestimo(ID_Usuario, ID_Emprestimo); frmEmprestimo.MdiParent = MdiParent; frmEmprestimo.Show(); }
private void btnEmprestimo_Click(object sender, System.EventArgs e) { bool found = false; foreach (Form openForm in Application.OpenForms) { if (openForm is FrmEmprestimo) { openForm.Focus(); found = true; } } if (!found) { FrmEmprestimo frmEmprestimo = new FrmEmprestimo(login.ID); frmEmprestimo.MdiParent = this; frmEmprestimo.Show(); } }