i made a sudoku game using windows forms, the datagrid was very easy to handle, for example
dataGridView1[2,3]=5;
now in wpf the datagrid cant be used like this and i need to find the easiest way to test and fill the grid, for example i had codes like :
for (i = 0; i < 9; i++)
{
for (j = 0; j < 8; j++)
{
for (k = j + 1; k < 9; k++)
{
if (dataGridView1[i, k].Value != null)....
}
}
}
}
any help?
I would not read the content of the dataGridView. Instead I would bind a control (such as the datagridview) to a data structure that represents the values in the Sudoku.
This would allow you to simply check the data structure (even add methods, properties and events to it)
Just make a Grid (9×9 cells) and a textblock in each cell and bind the text property of each cell to an element of a two dimensional array:
And set the Grid’s DataContext in code:
Now you can simply set and check
_sudoku.Cells[2,3]