firas shaar

firas shaar

  • NA
  • 15
  • 17.6k

how to delete multirows

Sep 14 2014 11:33 AM
hi
 I delete rows in datagridview using chcekbox column
I write the following code
 
private void btndelpay_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("delete row", "do you want to delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (dr == DialogResult.Yes)
{
DataGridViewRow row = new DataGridViewRow();
for (int i = 0; i < gridviewimppays.Rows.Count; i++)
{
row = gridviewimppays.Rows[i];
if (Convert.ToBoolean(row.Cells[0].Value) == true)
{
if (ImprestsPaysMgr.DeleteImprestsPays(int.Parse(row.Cells["ID"].Value.ToString())))
gridviewimppays.Rows.Remove(row);
i--;
}
my prolblem is 
how to cancel check from rows in datagridview in chechboxes column  when the user select dialogResult.NO

Answers (2)