0
當我將鼠標懸停在C#上時,如何更改PicureBox的背景圖像? 我正在使用visual c#2010 Express。 謝謝在C#中的鼠標懸停更改PictureBox的背景圖像?
當我將鼠標懸停在C#上時,如何更改PicureBox的背景圖像? 我正在使用visual c#2010 Express。 謝謝在C#中的鼠標懸停更改PictureBox的背景圖像?
你只需要訂閱MouseHover事件更改圖像屬性。
這應該做的伎倆:
PictureBox o = new PictureBox();
o.MouseHover += (a_sender, a_args) =>
{
PictureBox pic = a_sender as PicureBox;
pic.Image = null // New Image..
};
同樣,當你需要恢復以前的圖片使用:MouseLeave
在PictureBox的性質,對事件MouseEnter雙擊和使用:
(sender as PictureBox).Image = Image.FromFile(// path of image1);
然後雙擊事件MouseLeave並使用:
(sender as PictureBox).Image = Image.FromFile(// path of image2);
FromFile或FromStrean ... – ndukan