我正在尝试获取网格视图中已编辑单元格的单元格值。有人能帮我学语法吗?此代码适用于网格视图中的第一行:
Dim Q As Integer = e.NewValues(e.RowIndex)但是如果我更新第2行,我会收到并出错...我的变量是“":
Index was out of range. Must be non-negative and less than the size of the collection.这将打印当前正在编辑的正确行:
System.Diagnostics.Debug.Print(e.RowIndex)我甚至尝试过直接获取单元格值:
Dim Qoh As Integer = CInt(gvInventory.Rows(e.RowIndex).Cells(2).Text)出现错误:
Conversion from string "" to type 'Integer' is not valid.发布于 2013-01-15 02:05:22
下面的代码解决了我的问题:
Dim Qoh As Integer = CInt(e.NewValues(0))我认为这是因为这是网格中唯一可编辑的单元格。
发布于 2013-01-14 22:11:09
Dim Qoh As Integer = CType(gvInventory.SelectedRows(0).Cells(2).Text, Integer) 试试这个..。
https://stackoverflow.com/questions/14319703
复制相似问题