I've recently started to learn c#, and I started off by making a simple tic-tac-toe game, using labels and forms.
When I click on a label I want it to change background color and Foreground color.
Here is my code;
public void LabelClick(Label lbl, int i)
{
if (strCurrPlayer == strPlayer1)
{
liP1Squares.Add(i);
lbl.BackColor = System.Drawing.Color.Black;
lbl.ForeColor = System.Drawing.Color.White;
lbl.Text = "X";
}
else
{
//Player2
liP2Squares.Add(i);
lbl.BackColor = System.Drawing.Color.White;
lbl.ForeColor = System.Drawing.Color.Black;
lbl.Text = "O";
}
lbl.Enabled = false;
SwapPlayer();
}
However, when it's called, it sets the background color correctly, but the foregorund, i.e. text, changes from the red, (default) to black for player 1 instead of White, and Light Grey for player 2, instead of Black.
I was wondering if there are any fields within Label or Forms that change text color by default when the background color is changed. If not, what else could be making this change?
Any help would be appreciated.
lbl.Enabled = false
? – bash.dlbl.Clickable = false
for example? – Alex