Deleting cell in Data grid

This code shows how to delete cells in data grid.


private void Delete_Cell(int iRow, string strValue, DataGridView dtGridview)
{
int k = 0;
ArrayList arrLst = new ArrayList();
for (k = 0; k <= dtGridview.ColumnCount - 1; k++)
{
if (Convert.ToString(dtGridview.Rows[iRow].Cells[k].Value)!="")
{
arrLst.Add(Convert.ToString(dtGridview.Rows[iRow].Cells[k].Value));
dtGridview.Rows[iRow].Cells[k].Value = "";
}
}


for (int i = 0; i <= arrLst.Count - 1; i++)
{
dtGridview.Rows[iRow].Cells[i].Value = Convert.ToString(arrLst[i]);
}
}


Regards
Anil Kumar


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: