private void salesDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { string si, column; DataGridViewRow row = salesDataGridView.Rows[e.RowIndex]; try { column = salesDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); si = salesDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString(); } catch (Exception exception) { return; } if (column.Equals("Edit")) { } if (column.Equals("Delete")) { _salesManager.DeleteFromCart(si); } if (_salesManager.productDetailsList.Count == 0) { ClearUI("productDetails"); } else { salesDataGridView.DataSource = null; salesDataGridView.DataSource = _salesManager.productDetailsList; FillTotalAndAll(); } }