private void dgvFoodItem_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == 6) { Int32 itemID = Convert.ToInt32("0" + dgvFoodItem.Rows[e.RowIndex].Cells[0].Value); UpdateFoodItemCtl objUpdate = new UpdateFoodItemCtl(itemID); 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); } else if (e.ColumnIndex == 7) { if (MessageBox.Show("Are you sure you want to delete the selected category?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int itemID = 0; bool bTempBool = Int32.TryParse(dgvFoodItem.Rows[e.RowIndex].Cells[0].Value.ToString(), out itemID); if (bTempBool) { CCategory3 oCat = new CCategory3(); oCat.Category3ID = itemID; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.DeleteCat3(oCat); if (oResult.IsSuccess) { dgvFoodItem.Rows.RemoveAt(e.RowIndex); } } } } } catch (Exception exp) { throw exp; } }