private void dgvReceiptStyles_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == 5) { Int32 receiptID = Int32.Parse(dgvReceiptStyles.CurrentRow.Cells[0].Value.ToString()); UpdateReceiptStyle objUpdate = new UpdateReceiptStyle(receiptID); objUpdate.Parent = this.ParentForm; UserControlManager.UserControls.Push(this); Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"]; string s = pnl.Name; objUpdate.ParentForm.Controls[s].Controls.Clear(); objUpdate.ParentForm.Controls[s].Controls.Add(objUpdate); } } catch (Exception exp) { MessageBox.Show(exp.Message + "Error Occured. Please contact to your administrator.", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }