开发者

controls PictureBox question

开发者 https://www.devze.com 2023-02-11 08:14 出处:网络
i have this Enum publicenum Icon { Question= 1, Hand= 2, 开发者_如何学JAVAExclamation = 3, None= 4 } i have 4 PictureBox on my Form named

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消