Try to use the code below. If you will select several cells than the button sets the value to zero only for the first cell.
private void button1_Click(object sender, EventArgs e)
{
var selected = dataGridView1.SelectedCells[0];
dataGridView1.Rows[selected.RowIndex].Cells[selected.ColumnIndex].Value = 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.