0

我在此代码的第三行中收到错误消息,即“对象引用未设置为对象的实例”。可能的原因是什么?

Dim table As New DataTable()
Me.bindingSource1.DataSource = table
Me.bindingSource1 = DataGridView1.DataSource
table = Me.bindingSource1.DataSource

我只需要知道可能的原因

4

2 回答 2

0

“我”为空(在 VB 中为空)或 DataGridView1 为空。造成这种情况的原因可能在您的代码中的其他地方。使用调试器找出答案。

于 2013-03-04T06:09:03.710 回答
0

可能DataGridView1nothing,没有问题,Me因为执行越过第二行而没有任何中断。检查是否DataGridView1没有。

  • 在第 3 行设置 a break point
  • break point罢工时,按(Ctrl+I立即窗口)
  • 输入?DataGridView1那个。
  • 然后按ENTER,你会发现它是否nothing存在。
于 2013-03-04T06:45:34.827 回答