private void frmAccountLedgerMasterAddUpdate_FormClosed(object sender, FormClosedEventArgs e) { try { ExtensionMethods.RemoveChildFormToPanel(this, (Control)sender, ExtensionMethods.MainPanel); LoadDataGrid((int)cbLedgerType.SelectedValue); frmAccountLedgerMasterAddUpdate frm = (frmAccountLedgerMasterAddUpdate)sender; if (dgvAccountLedger.Rows.Count > 0) { int id = frm.AccountLedgerId; foreach (DataGridViewRow row in dgvAccountLedger.Rows) { if (row.Cells["AccountLedgerId"].Value.ToString().Equals(frm.AccountLedgerId.ToString())) { dgvAccountLedger.Rows[row.Index].Selected = true; if (row.Index != 0) { dgvAccountLedger.Rows[0].Selected = false; } break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OpenAddEdit(int accountLedgerId) { frmAccountLedgerMasterAddUpdate form = new frmAccountLedgerMasterAddUpdate(accountLedgerId, txtSearch.Text); form.IsInChildMode = true; form.FormClosed -= frmAccountLedgerMasterAddUpdate_FormClosed; form.FormClosed += frmAccountLedgerMasterAddUpdate_FormClosed; form.ShowDialog(); }