Hi all,

I am having issue with my datagrid view. I plcaed some code in the 'SelectionChanged' event of the control.
What the code does is it assigns items based on index to textbox items. This exception is raised when ever I click on the column header of the data grid view.

What seems to be the problem?

Thankyou

Recommended Answers

All 6 Replies

I don't know with the info you provided.
The only thing I can tell for sure is that you acsessed an object before initializing it.

@ what ddanbe said. You need to show your code, or at least describe what your are doing more completely.

Sorry I thought I attached a picture of the code with the exception...
Here's the code I wrote and the exception 1.png

Your error means that the Value in your DGV cell must be null. Add an if statement to test for that.

Actually I have a set of populated records in the data grid view.

Try this X = dataGridView1[Column,Row].Value;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.