建立了一个数据连接,Data GridView里面也有数据显示,就是我用下面的方法取值时提示错误
未将对象应用设置到对象实例化,
MessageBox.Show(this.dataGridView1.Rows[2].Cells[1].Value.ToString())
是什么原因?
未将对象应用设置到对象实例化,
MessageBox.Show(this.dataGridView1.Rows[2].Cells[1].Value.ToString())
是什么原因?
this.dataGridView1.Rows[2].Cells[1].Value 是多少
------------------------------
语句没写错。
很明显语句执行时某个变量引用的对象为空(null)才报这样的异常。
你设断点看看是哪个值为null。
这样不会报错了