'How to delete the current cell in DataGridView?

How can I delete a current cell in a DataGridView. I am trying the code below, but it is deleting all cells except the current one.

private void dgvPurchase_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
    for (int i = 0; i < datagridview.Columns.Count; i++)
    {
        for (int j = 0; j < datagridview.Rows.Count; j++)
        {
            datagridview.Rows[j].Cells[i].Value="";
        }
    }
}


Solution 1:[1]

The following link describe how to achive what you want ,
Please check the link , I am sure that will help you ,

http://msdn.microsoft.com/en-us/library/yc4fsbf5.aspx

Solution 2:[2]

I don't know why you do deleting cell value in CellValidating Event ..

To delete value in CurrentCell .. you may try

DataGridView1.CurrentCell.Value = ""

Solution 3:[3]

I'm not %100 sure but you can use DataGridView.CurrentCell property like;

int yourcolumnIndex = datagridview.CurrentCell.ColumnIndex;
int yourrowIndex = datagridview.CurrentCell.RowIndex;

datagridview.Rows[yourrowIndex ].Cells[yourcolumnIndex].Value="";

Or even using DataGrid.CurrentCellChanged event could be better approach.

Solution 4:[4]

You can try:

DataGridName.Rows.RemoveAt(DataGridName.CurrentCell.RowIndex);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 matzone
Solution 3 marc_s
Solution 4 Suraj Rao