首页 > 解决方案 > Vb.Net DataGridView 代码错误 - 对象引用未设置为对象的实例

问题描述

我在尝试遍历 VB.Net 中 DataGridView 中的行时收到错误消息“对象引用未设置为对象实例”

     ' This works smooth and returns output as 5
      MsgBox(DtaGrid_Tasks.Rows.Count) 

      'This throws error in first line itself
        For j As Integer = 0 To DtaGrid_Tasks.Rows.Count - 1
            MsgBox(DtaGrid_Tasks.Rows(j).Cells(3).Value.ToString)
        Next

      'Also tried this but getting same error
        For Each dRow As DataGridViewRow In DtaGrid_Tasks.Rows
            'Other codes
        Next 

标签: vb.netdatagridview

解决方案


推荐阅读