我正在Visual Studio 2010中创建一个Windows窗体应用程序。我需要制作一个具有不同图像的鼠标悬停和mousedown事件更改的按钮。如何制作更改鼠标悬停事件外观的按钮?
我用这个:
public Form1()
{
InitializeComponent();
button1.MouseEnter += new EventHandler(button1_MouseEnter);
button1.MouseLeave += new EventHandler(button1_MouseLeave);
}
void button1_MouseLeave(object sender, EventArgs e)
{
this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.img1));
}
void button1_MouseEnter(object sender, EventArgs e)
{
this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.img2));
}
我保存在资源中的图像以 “IMG1” 和 “IMG2”。但是,他们不被承认。
this.button1.BackgroundImage = ((System.Drawing.Image对象)(Properties.Resources IMG2)。);
在这个例子中,放置什么而不是“img2”?如何从资源访问图像? 该按钮也有一个斜角边框。如何删除它?
希望我自己清楚,你明白我的问题...... 弗拉德
什么错误信息您收到?您是否尝试过使用Clean Build和Rebuild重新构建程序集中的资源? – 2011-02-23 11:26:45
“他们无法识别”是什么意思? – 2011-02-23 11:27:23