簡體   English   中英

更改鼠標懸停在C#中PictureBox的背景圖像?

[英]Change background image of PictureBox on mouseover in C#?

當我將鼠標懸停在C#中時,如何更改PicureBox的背景圖像? 我正在使用Visual C#2010 Express。 謝謝

您只需要向MouseHover Event訂閱一個更改Image屬性。

這應該可以解決問題:

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM