i have this Enum
public enum Icon
{
Question = 1,
Hand = 2,
开发者_如何学JAVAExclamation = 3,
None = 4
}
i have 4 PictureBox on my Form named
P1 , P2 , P3 and P4
if i have Icon G
how i can show any PictureBox like this:
Instead of P2.visible = true
i'll write G.Hand = True
thanks in advance
I think there's no need for four PictureBox
controls, you just need to have one and select an image base on your enum like the following:
// Assuming you have a dictionary of icons pathes
Dictionary<Icon,string> icons = new Dictionary<Icon,string>();
icons[Icon.Question] = "..\imgQuestion.png" \\ path of question image";
icons[Icon.Hand] =
icons[Icon.Exclamation] =
pictureBoxControl.Image = icons[G.Hand];
Good luck!
精彩评论