我正在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