broli100 0 Newbie Poster

Hello, I am doing simple program with Visual Studio and I am using System.Windows.Forms. It has DataGridView, which represents sudoku board. Everything goes OK, but when I manually edit some cell, then the program crashes and throws some exception, which has something to do with unproper conversion of types.

Here is my part of code, which copies values of cells to normal array of integers:

    #define Copy(stav)\
    {\
        for(int i=0;i<9;i++)\
        {\
           for(int j=0;j<9;j++)\
           {\
              sudoku[j][i]=(int)System::Convert::ToInt32(this->DGW_A[i,j]->Value);\
           }\
        }\
        }

Program works OK with cells that I change by program, but when I enter value for example to cell [2,2], then it falls on the line with conversion. Current cell of DGW_A is [2,2]. I would thing that it has something to do with ValueType property, but i don't know. My question is what is working conversion between value of DGW and int.

Thanks for reply.

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.