【发布时间】:2015-02-12 00:53:00
【问题描述】:
我是 vb.net 和论坛的新手,从中学到了很多,我在表单加载事件中自动将数据从 xml 文件导入到 datagridview,现在我需要一种方法来对某些列进行计算同样在表单加载事件中,我不想通过单元格更改或单元格结束编辑事件来做到这一点,就像我有这样的代码:
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
Try
Dim order As DataGridView = DirectCast(sender, DataGridView)
If IsDBNull(order(0, e.RowIndex).Value) Then Exit Sub
order("column name", e.RowIndex).Value = order("column name", e.RowIndex).Value * textboxvalue.Text
Catch ex As Exception
End Try
End Sub
它工作正常,但我必须点击每个单元格并标签才能看到结果! 许多单元格点击不是好方法!
这样做的最佳方法是什么? 提前致谢
【问题讨论】:
-
加载后,
For/Loop怎么样?For Each row As DataGridViewRow In dgv.Rows -
谢谢 OneFineday ..你能给我更多的细节或代码
-
我的答案不应该明确使用 - 您需要决定使用哪些单元格。另外,它对计算没有任何作用。你需要决定如何处理它。请记住,它们是基于 0 的。
标签: vb.net datagridview