I want to do the following:
string WhoIsTheSender="pictureBox1";
switch (WhoIsTheSender)
{
case "pictureBox1":
pictureBox1.Image = Properties.Resources.ledOff;
break;
case "pictureBox2":
pictureBox2.Image = Properties.Resources.ledOff;
break;
//....until case "pictureBox64": pictureBox64.Image = Properties.Resources.ledOff;
break;
}
Is there a possible way to make it much shorter? How do I use reflection?
string WhoIsTheSender="pictureBox1";
WhoIsTheSender.Image = Properties.Resources.ledOff; //in this specific example WhoIsTheSender="pictureBox1";
Thank for the helps in advance!
Aucun commentaire:
Enregistrer un commentaire