首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

DataGridView中获取最后一列值出现的有关问题

2012-04-21 
DataGridView中获取最后一列值出现的问题DataGridView中很简单只有4列,第一行每列都填好数据后,触发事件弹

DataGridView中获取最后一列值出现的问题
DataGridView中很简单只有4列,第一行每列都填好数据后,触发事件弹出MsgBox,把该行每列的数据都显示一遍。

代码如下:
  Dim index As Integer = DataGridView1.NewRowIndex - 1
  MsgBox(DataGridView1.Rows(index).Cells(0).Value)
  MsgBox(DataGridView1.Rows(index).Cells(1).Value)
  MsgBox(DataGridView1.Rows(index).Cells(2).Value)
  MsgBox(DataGridView1.Rows(index).Cells(3).value)


显示到最后一列时就会显示空值,而改变列数测试时,都是只有最后一列没有值,请问这是什么问题?


[解决办法]
有没有隐藏的列?
[解决办法]
最后一个单元格应该是要失去焦点或要按下回车后才会生效的吧?
[解决办法]
设置一下DataGridView的属性就可以了。
[解决办法]
DataGridView1.EndEdit()

热点排行