【发布时间】:2009-12-14 16:18:44
【问题描述】:
我的计划是创建一个单独的活动:
"好的,鼠标进入一个注册的pictureBox,根据发送者的名字加载X图片。"
处理这个问题的最佳方法是什么?
要不要创建一个字典,名字为key,图片资源的位置为value?
这是我目前所拥有的:
private void SetPictureBoxEvents()
{
Andromeda.MouseEnter += new EventHandler(HeroMouseEnter);
Engineer.MouseEnter += new EventHandler(HeroMouseEnter);
Nighthound.MouseEnter += new EventHandler(HeroMouseEnter);
Swiftblade.MouseEnter += new EventHandler(HeroMouseEnter);
}
void HeroMouseEnter(object sender, EventArgs e)
{
//My picture box is named Andromeda. I'm going use that name
// as a key is a Dictionary and pull the picture according to the name.
//This is to make a generic event to handle all movements.
//Any help?
// ((PictureBox)sender).Image =
}
我怎样才能在我的资源中为图像位置创建字典。:
Dictionary<string, TestProject.Properties.Resources> HeroList
= new Dictionary<string, TestProject.Properties.Resources>();
这不起作用。
【问题讨论】:
标签: c# .net winforms dictionary