Gali
Gali

Reputation: 14973

controls PictureBox question

i have this Enum

public  enum Icon
{
    Question    = 1,
    Hand        = 2,
    Exclamation = 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

Upvotes: 0

Views: 126

Answers (1)

Homam
Homam

Reputation: 23871

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!

Upvotes: 2

Related Questions