dataGridView1.Rows[e.RowIndex].Cells[4].Value = int.Parse((dataGridView1[3, e.RowIndex].Value.ToString())) + int.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
就是 单元格2=单元格2+单元格1
比如i=i+1;这里变成表格就成了死循环了呢?
就是 单元格2=单元格2+单元格1
比如i=i+1;这里变成表格就成了死循环了呢?
{
if (e.RowIndex >= 0)
{
int i = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
dataGridView1.Rows[e.RowIndex].Cells[4].Value = int.Parse((dataGridView1[3, e.RowIndex].Value.ToString())) + i;
}
}代码就是有单元格数据发送改变(就是我重新录了值进某个单元格),就把当前行的:第4列=第4列+第3列的值,但是这里一直显示死循环。
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if(check)
{
if (e.RowIndex >= 0)
{
int i = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
dataGridView1.Rows[e.RowIndex].Cells[4].Value = int.Parse((dataGridView1[3, e.RowIndex].Value.ToString())) + i;
check=false;
}
}
else
{check=true;}
}
{
all right;
}