C# DEV 控件gridview 在给指定单元格赋值时出错,怎么解决

for (int i = 0; i <gridView1.RowCount; i++)
{
//object sl = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "SL");
//object dj = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DJ");
//if (sl != System.DBNull.Value && dj != System.DBNull.Value)
//{
// int a = Convert.ToInt32(sl);
// Decimal b = Convert.ToDecimal(dj);
this.gridView1.SetRowCellValue(i, gridView1.Columns["HJ"],4);

          //  }
        }
         this.gridView1.SetRowCellValue(i, gridView1.Columns["HJ"],4);我debug了这句代码,发现无线循环执行这个代码,求解           

        用这个代码时回报对象为实例化this.gridView1.GetDataRow(i)["HJ"] = (a*b).ToString();

1个回答

已经解决,代码如下:
int i = e.RowHandle;
object sl = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "SL");
object dj = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DJ");
if (sl != System.DBNull.Value && dj != System.DBNull.Value)
{
int a = Convert.ToInt32(sl);
Decimal b = Convert.ToDecimal(dj);

                this.gridView1.GetDataRow(i)["HJ"] = (a*b).ToString();
            }
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!