郭老师的小迷弟雅思莫了
2017-04-19 02:59
采纳率: 100%
浏览 3.4k

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();
                }
    
    已采纳该答案
    1 打赏 评论

相关推荐 更多相似问题