【发布时间】:2014-12-04 04:51:21
【问题描述】:
我想用这个在我的 datagridview 中插入值:
For Each rows As DataGridViewRow In dgView.Rows
rows.Cells("Ave").Value = Format(Val(dgView.Rows(0).Cells("Qty Issued")) / countMonths).ToString
Next
但是有这个错误:“Argument 'Expression' cannot be convert to type 'DataGridViewTextBoxCell'.”
这是场景:
我得到了一个由数据库中的数据填充的 datagridview。我以编程方式添加了列名“Ave”,然后我想获取其中一列的平均值并使用循环将其放置到添加的列“Ave”中。顺便说一句,我愿意接受建议。
感谢所有提供帮助的人,我在大约一天后才弄明白。这是我使用的新代码:
For Each rows As DataGridViewRow In dgView.Rows
ave = rows.Cells("Qty Issued").Value / countMonths
rows.Cells("Ave").Value = Format(ave, "0.00")
Next
【问题讨论】:
-
@nempoBu4 仍然有同样的错误
标签: vb.net datagridview