Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I created a DataGridViewComboBoxColumn in run time and I found the selected item, but when I wrote this code in my project it returns null

C#
datagridview1.Rows[i].Cells[0].Value.ToString();


Please Help Me
Posted
Updated 29-Oct-11 19:48pm
v2
Comments
Menon Santosh 30-Oct-11 2:35am    
Check the value on cellvaluechanged event

1 solution

By "it returns null" I assume that you mean you get a Null Reference exception - ToString cannot return null.

The question is, what does the rest of your code look like?

You say you are creating this at run time - did you put any values in? Did you set a value for the combobox or leave it as a blank drop down?
Where did you put that code? In the SelectionChanged event? If so, then you will get an event (and a null reference) when the DataGridView is first created.
 
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