I am using the PictureBox class to create a checkerboard, and it not really working all that well. I've created the loop:
PictureBox[,] squares = new PictureBox[10,10];
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
squares[i, j] = new PictureBox();
squares[i,j].Image = Chess.Properties.Resources.square;
squares[i, j].BackColor = Color.Transparent;
}
}
for (int i = 0; i < 10; i++)
{
for(int j = 0; j < 10; j++)
{
squares[i, j].Location = new Point(i * 30, j * 30);
this.Controls.Add(squares[i, j]);
}
}
It's supposed to create a 10x10 grid, and I added the image into the application resources. Each square is 20x20 pixels, and I loop by column. I thought it would work, but all I get is 6 images and the size just gets smaller.
Am I missing something? Or any good alternatives in creating a checkerboard without using PictureBox? Any thing with a MouseLeave, MouseHover, MouseClick, events I can use.
i*20, j*20ori*40, j*40. – pimvdb Mar 27 '11 at 11:50