For循环的问题
foreach里嵌套了2个for循环,编译时提示第2个for循环无法访问到
foreach (DataGridViewRow currentrow in dataGridView2.Rows)
{
string str_jhbh = currentrow.Cells["jhbh"].Value.ToString();
for(int int_row=0;int_row<dataGridView3.Rows.Count;int_row++)
{
if(dataGridView3.Rows[int_row].Cells["jhbh_jh"].Value.ToString()==str_jhbh)
{
dataGridView3.Rows[int_row].Cells["kcsl"].Value = Convert.ToInt32(dataGridView3.Rows[int_row].Cells["kcsl"].Value.ToString()) +
Convert.ToInt32(currentrow.Cells["xssl"].Value.ToString());
dataGridView3.Rows[int_row].Cells["thsl_jh"].Value=Convert.ToInt32(dataGridView3.Rows[int_row].Cells["thsl_jh"].Value.ToString())-
Convert.ToInt32(currentrow.Cells["thsl"].Value.ToString());
break;
}
}
for(int int_row=0;int_row<dataGridView4.Rows.Count;int_row++)//这句提示无法访问的代码
{
if (dataGridView4.Rows[int_row].Cells["mxbh_mx"].Value.ToString() == currentrow.Cells["mxbh"].Value.ToString())
dataGridView4.Rows.RemoveAt(int_row);
break;
}
dataGridView2.Rows.Remove(currentrow);
}