以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  ”运行错误“提示  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=79311)

--  作者:tjzj_lyl
--  发布时间:2015/12/28 21:19:00
--  ”运行错误“提示
请问老师:
     在运行如下代码时出现错误提示,该如何修改?错误提示如下:
          .NET Framework 版本:2.0.50727.3655
          Foxtable 版本:2015.11.11.1
          错误所在事件:全局表事件,BeforeAddDataRow
          详细错误信息: Object reference not set to an instance of an object.
     代码如下:
           DataTables("贷款利息计算").dataRows.clear()
           Tables("贷款利息计算").AddNew()
      全局表事件BeforeAddDataRow
      If Tables(e.DataTable.Name).Current.DataRow.RowState <> DataRowState.Unchanged Then
           e.Cancel=True
           MessageBox.Show("当前行数据已被修改 请先保存数据再换行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question)
      End If

谢谢

--  作者:大红袍
--  发布时间:2015/12/28 21:35:00
--  

带改一下

 

      If  Tables(e.DataTable.Name).Current IsNot Nothing AndAlso Tables(e.DataTable.Name).Current.DataRow.RowState <> DataRowState.Unchanged Then

           e.Cancel=True
           MessageBox.Show("当前行数据已被修改 请先保存数据再换行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question)
      End If

--  作者:tjzj_lyl
--  发布时间:2015/12/28 21:39:00
--  
好的 谢谢