This section of code is misbehaving. I want to draw a user defined grid of circles with each a random color from a set list of 7 colors. The random number generator is supposed to do this. The grid of circles gets drawn fine, its the colors that are giving me grief. I seem to get a max of two colors per grid, with the first dozen being one color and the rest being a second color. Its strange, as the code should cycle through the color generator, then draw one circle and repeat. Please help me find the troublesome lines, Spent far too long trying by myself!
Ignore references to JEWEL_HEIGHT and similar, they are just variable names relevant to the program.
int columns = int.Parse(textBoxColumns.Text);
int rows = int.Parse(textBoxRows.Text);
for (int y = 0; (y < rows * 20); y += JEWEL_HEIGHT)
{
for (int x = 0; (x < columns * 20); x += JEWEL_WIDTH)
{
Color brushColor = (Color.Red);
Random randGen = new Random();
int randColor = randGen.Next(7);
if (randColor == 0)
brushColor = (Color.Red);
else if (randColor == 1)
brushColor = (Color.Orange);
else if (randColor == 2)
brushColor = (Color.Yellow);
else if (randColor == 3)
brushColor = (Color.Green);
else if (randColor == 4)
brushColor = (Color.Blue);
else if (randColor == 5)
brushColor = (Color.Indigo);
else if (randColor == 6)
brushColor = (Color.Violet);
Graphics paper = pictureBoxJewels.CreateGraphics();
SolidBrush brush = new SolidBrush(brushColor);
paper.FillEllipse(brush, x, y, JEWEL_WIDTH, JEWEL_HEIGHT);