I am working on a project in .NET using windows forms application. I need to copy the data from datagridview to 2D array but i am getting error. Here is my code. Here i am just trying to copy a single element to an integer.
int x = dataGridView1->Rows->Cells->Value;
the error i get is
'=' : cannot convert from 'System::Object ^' to 'int '
Hmm.. Try changing 'x' to a var, rather than int and see what that gives you.
var x = dataGridView1->Rows->Cells->Value;
Somewhat of a bad idea. var would make that specific error go away, but then x would be whatever type that he was trying to force into that integer. He's not going to be able to make use of it correctly later. Also, why are you using the dereferencing operator? Are you storing dataGridView1 as a pointer? Is this C++ or C# code?