2012-02-15 57 views
0

我很想知道为什么这个代码把值5在列的单元格datagridview的形式负载

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 

回答

0

请尽量细胞指标,而不是小区名称。

// 1是细胞指数

row.Cells(1).Value = 5 
+0

硬编码值正常工作,即使列名,配方没有,这就是问题 – dinotom 2012-02-15 01:28:25

+0

好难过。对于公式,转换十进制或整数。 Integer.Parse( “23”);或Decimal.Parse(“23.20”) – 2012-02-15 01:38:30