I don't see anything here which has to do with inheritance, and I am not quite sure what you problem is: there is nothing about colour in your code, except a few disconnected bits an pieces.
However, you have complicated your code quite a bit unnecessarily. Instead of a single loop to create a row and column matrix, it is a lot clearer if you use a pair of nested loops:
Point buttonLocn = new Point(0, 56);
Size buttonSize = new Size(30, 30);
int locX = buttonLocn.X, locY = buttonLocn.Y;
int i = 1;
for (int xButton = 0; xButton < numberOfColumns; xButton++)
{
locY = buttonLocn.Y;
for (int yButton = 0; yButton < numberOfRows; yButton++)
{
Button x = new Button();
x.Name = "x" + i.ToString();
i++;
x.Size = new Size(buttonSize.Width, buttonSize.Height);
x.Location = new Point(locX, locY);
x.Click += new EventHandler(x_Click);
x.Location = new Point(locX, locY);
locY += buttonSize.Height;
pictureBox1.Controls.Add(x);
}
locX += buttonSize.Width;
}
Note that I have replaced your "magic numbers" with more readable versions.
I'm not sure what you need, but this is simple code to change the colour when you click a button:
private void x_Click(object sender, EventArgs e)
{
Button b = sender as Button;
if (b != null)
{
b.BackColor = GetTurnColor();
}
}
int turn = 0;
private Color GetTurnColor()
{
turn++;
if ((turn & 1) == 0)
{
return Color.Red;
}
return Color.Blue;
}
Each time you click, the button colour will be set red or blue, alternating.