private void dataGrid1_CurrentCellChanged(object sender, EventArgs e) { string barCode = string.Empty; int row = dataGrid1.CurrentRowIndex; int col = dataGrid1.CurrentCell.ColumnNumber; int iRow; int iCol; DataTable myTable; bool gotoback = false; myTable = (DataTable)dataGrid1.DataSource; for (iRow = 0; iRow < myTable.Rows.Count; iRow++) { if (row == iRow) { for (iCol = 0; iCol < myTable.Columns.Count; iCol++) { barCode = Convert.ToString(dataGrid1[iRow, 1]); break; } } } if (col == 2) { if (MessageBox.Show("�س��ͧ���ź�������Ţ��� :" + barCode + " ��������� ?", "����ѹ", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { ProductService service = new ProductService(); bool delete = service.deleteDocCheckProduct(barCode); if (delete) { MessageBox.Show("ź���������º�������� !!! ", "����"); Console.WriteLine(" Delete Sueess"); loadData(); return; } } else { return; } } }