Im trying to make my Start button generate a Color in all of those 4 boxes marked on the top of the Picture. The Colors should not be the same. Its supposed to work like Lotto but with Colors instead of numbers. Can anyone please tell me whats wrong with my code?
And thats my code;
}
private void buttonStart_Click(object sender, EventArgs e)
{
buttontest.BackColor = GetRandomColor();
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
Color RandomColor = GetRandomColor();
buttontest.BackColor = GetRandomColor();
buttontest.Refresh();
}
private Random random;
private void MainForm_Load(object sender, EventArgs e)
{
//Create a new instance of the random class
random = new Random();
}
private Color GetRandomColor()
{
return Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
}
private void buttontest_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
buttontest.BackColor = Color.Red;
}
}
}