private void FormSupplierLedgerAddUpdate_FormClosed(object sender, FormClosedEventArgs e) { try { ExtensionMethods.RemoveChildFormToPanel(this, (Control)sender, ExtensionMethods.MainPanel); LoadDataGrid(); frmSupplierLedgerAddUpdate frm = (frmSupplierLedgerAddUpdate)sender; if (dgvSupplier.Rows.Count > 0) { int id = frm.SupplierId; foreach (DataGridViewRow row in dgvSupplier.Rows) { if (row.Cells["SupplierLedgerId"].Value.ToString().Equals(frm.SupplierId.ToString())) { dgvSupplier.Rows[row.Index].Selected = true; if (row.Index != 0) { dgvSupplier.Rows[0].Selected = false; } break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void AddEditSupplierLedger(int supplierId) { frmSupplierLedgerAddUpdate frmSupplierAddUpdate = new frmSupplierLedgerAddUpdate(supplierId, txtSearch.Text); frmSupplierAddUpdate.IsInChildMode = true; ExtensionMethods.AddChildFormToPanel(this, frmSupplierAddUpdate, ExtensionMethods.MainPanel); frmSupplierAddUpdate.WindowState = FormWindowState.Maximized; frmSupplierAddUpdate.FormClosed += FormSupplierLedgerAddUpdate_FormClosed; frmSupplierAddUpdate.Show(); }