6
I have 5 background images for my application and that will be visible to the user’s taste. What is the simplest way (clean code) to get the user to choose?
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
pictureBox1.Visible = true;
pictureBox2.Visible = false;
pictureBox3.Visible = false;
pictureBox4.Visible = false;
pictureBox5.Visible = false;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
pictureBox2.Visible = true;
pictureBox1.Visible = false;
pictureBox3.Visible = false;
pictureBox4.Visible = false;
pictureBox5.Visible = false;
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
pictureBox1.Visible = false;
pictureBox2.Visible = false;
pictureBox3.Visible = true;
pictureBox4.Visible = false;
pictureBox5.Visible = false;
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
pictureBox1.Visible = false;
pictureBox2.Visible = false;
pictureBox3.Visible = false;
pictureBox4.Visible = true;
pictureBox5.Visible = false;
}
private void img5_CheckedChanged(object sender, EventArgs e)
{
pictureBox1.Visible = false;
pictureBox2.Visible = false;
pictureBox3.Visible = false;
pictureBox4.Visible = false;
pictureBox5.Visible = true;
}
There’s only one problem: what if there’s more than five
PictureBox
in theForm
and the others are not modified?– Leonel Sanches da Silva
@I don’t think that’s gonna be a problem, at least not for the OP, according to him, there are only 5
picturebox
.– stderr
Do you accept the suggestion? How about minimizing your response to a single event?
– Leonel Sanches da Silva
Now yes. Excellent. + 1.
– Leonel Sanches da Silva