datagridview表单加载

时间:2012-02-15 01:20:41

标签: vb.net datagridview

我很想知道为什么这段代码将值5放在列单元格

 For Each row As DataGridViewRow In Me.datagridADRORD.Rows
        row.Cells("Historical Diff").Value = 5
    Next

但是这段代码不起作用,即单元格留空。公式单元格中有值,因此应该有一个值放在计算列

 For Each row As DataGridViewRow In Me.datagridADRORD.Rows
        row.Cells("Historical Diff").Value = row.Cells("ADR Price").Value - row.Cells("ORD Price").Value
    Next

1 个答案:

答案 0 :(得分:0)

请尝试Cell索引,而不是Cell Name。

// 1是单元格索引

row.Cells(1).Value = 5