I have created new column against every new value of N now it displays only the last column of every row also the column name is started from '0' I want to start it from '1'
private void printBoard(int[,] board,int N)
{
for (int i = 0; i < N; i++)
{
DataGridViewRow row = new DataGridViewRow();
for (int j = 0; j < N; j++)
{
if (i > 0 || j > 0)
{
dataGridView1.ColumnCount = N;
row.CreateCells(dataGridView1);
dataGridView1.Columns[j].Name = j.ToString();
row.Cells[j].Value = board[i, j];
}
}
this.dataGridView1.Rows.Add(row);
}
}
Here is the output:

Nto the method, it should be the upper bound of 2nd dimention.