Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Orcun Iyigun 26-Feb-12 23:22pm    
have you tried using breakpoint to hat line and see what is the value that you are getting?
Sergey Alexandrovich Kryukov 26-Feb-12 23:57pm    
I'm thinking about marking such questions as off-topic. Why? Because this is a site for software developers and students. And a most rudimentary skill of the software developers is making things fly using the debugger. This exception is so easy to discover that using the debugger is the only required skill.
--SA

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
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Feb-12 23:54pm    
And one more, less likely: datagridview1 is null. My 5, anyway.
--SA
Sergey Alexandrovich Kryukov 26-Feb-12 23:58pm    
But more appropriate answer would be "use the debugger" -- please see my comment to the question.
--SA
Dhol Gaurav 27-Feb-12 0:26am    
ya right and we can easily solve this error by debugging, and this is the most most common error in the programing world :)
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900