Ok - so, I made an onscreen keyboard where the user turns the caps lock on and the box changes from black to white, then changes back when it's clicked again.
private void checkBox1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
checkBox1.BackColor = Color.White;
checkBox1.ForeColor = Color.Black;
checkBox1.Checked = false;
}
else
{
checkBox1.Checked = true;
checkBox1.BackColor = Color.Black;
checkBox1.ForeColor = Color.White;
}
}
This is how I think the above code works:
1 - Caps lock starts off (checked = false)
2 - User clicks caps lock (which changes checked to true)
3 - The code should change the box to white
4 - The box changes back to black when user clicks the button again (because checked = false)
I'm sure I'm misunderstanding this somewhere, but I can't nail it.
The point of this is that currently it isn't changing colour at all - somehow I forgot to add that.
Aucun commentaire:
Enregistrer un commentaire