private void toolStripButton3_Click(object sender, EventArgs e) { try { ado_project dd = new ado_project(); int i = dataGridView1.CurrentRow.Index; string cmp_name = dataGridView1.Rows[i].Cells[0].Value.ToString(); dd.delete_customer(cmp_name); dataGridView1.Refresh(); } catch (Exception) { MessageBox.Show("you can't Delete all companies"); } #region MyRegion //for (int i = 0; i < dataGridView1.SelectedRows.Count; i++) //{ // cmp_name = dataGridView1.SelectedRows[i].Cells[0].Value.ToString(); //} //if (dataGridView1.SelectedRows[0].Selected) //{ //} //else //{ MessageBox.Show("Please Select Company to Delete"); } #endregion }