出现错误“对象引用未设置为对象的实例". [英] The error Occured "Object Reference not set to an instance of an object"

查看:97
本文介绍了出现错误“对象引用未设置为对象的实例".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用datagridview中的combobox列.我想在组合框列中打印选定的值.所以我给

I am using combobox column in datagridview. I want to print the selected values in combobox column. So I give

datagridview1.Rows(0).Cell(0).value. Tostring



但是显示以下错误

对象引用未设置为对象的实例"

我怎么解决这个问题.请任何知道的人帮助我

谢谢



But the following Error is displayed

"Object Reference not set to an Instance of an object"

How can I solve this Problem. Please anybody Known help me

Thank you

推荐答案

有可能,请检查以下代码的值.

1)datagridview1.Rows(0),可能是您将此值作为NULL
2)datagridview1.Rows(0).Cell(0)还会检查此
的值 3)datagridview1.Rows(0).Cell(0).value

从上面您可能会得到一个值NULL
there are may possibility, check value of below code.

1) datagridview1.Rows(0), might be you are getting this value as NULL
2) datagridview1.Rows(0).Cell(0) also check the value of this
3) datagridview1.Rows(0).Cell(0).value

from the above you may get one of the value NULL


这是编程中的一个非常常见的错误,通常发生在未初始化控件或变量且使用其值的情况下用于计算.

出于一般原因,请参考此链接以了解发生此错误的原因:- ^ ]

如果您有帮助,请不要忘记将其标记为答案.

谢谢
This is a very common error in programming which usually occurs when a control Or variable is not being initialized and the value from it is being used for computation.

Please refer this link for general reasons as to why this error occurs:- http://codebetter.com/raymondlewallen/2005/06/23/system-nullreferenceexception-object-reference-not-set-to-an-instance-of-an-object-3-common-causes-in-vb-net/[^]

Please don''t forget to mark this as your answer if it helps you out.

Thanks


这篇关于出现错误“对象引用未设置为对象的实例".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆