Hello great coders,

I am writing a chess game in c# using windows forms and i need your help. I already wrote the code to get me the chess board but i need to populate the chess board with officials and this is where i got stuck. Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace chess5
    public partial class Form1 : Form
        private Panel[,] chessBoardPanels;

        public Form1()


        private void Form1_Load(object sender, EventArgs e)
            const int tileSize = 60;
            const int gridsize = 12;
            var clr1 = Color.DarkGray;
            var clr2 = Color.White;
            chessBoardPanels = new Panel[gridsize, gridsize];
            for (var n = 0; n < 8; n++)
                for (var m = 0; m < 8; m++)
                    var newPanel = new Panel
                        Size = new Size(tileSize, tileSize),
                        Location = new Point(tileSize * n, tileSize * m),
                    chessBoardPanels[n, m] = newPanel;

                    if (n % 2 == 0)
                        newPanel.BackColor = m % 2 != 0 ? clr1 : clr2;
                        newPanel.BackColor = m % 2 != 0 ? clr2 : clr1; 




That is the code that designs my chess board for me. but am kind of stuck on how to populate it with officials. Any help will be appreciated. Thanks

The game functionality should be seperate from the graphic representation of the game. Try to write the game in a command prompt mode only. Then you can represent the board as a 2-dim array and each array item contains a class of type official or is empty You shoould have code in place to select and move an official as well as determine possible moves based on type of official etc.
When this is done you can generate a graphic interface