string s = dataGridView1[0, 0].ToString(); string s2 = dataGridView1[0, 1].ToString();
I used the above method to access elements of datagridview. but i’m getting only these values in ‘s’ and ‘s2’ ‘DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=0 }’
‘DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=1 }’
but the values in datagrid are ‘1’,’hello’. how can i access it.?
You’ll notice that when you index into the DGV you get an instance of the DataGridViewTextBoxCell class. It does overload the ToString method, but not in the way you hoped/expected.
So you must get the value contained within this instance, then call ToString on it.