Mouse Over Event (C Sharp)
-
-
Dear, I have one panel and set its BackgroundImage as Image1. When I use mouse over the panel, I want to see panel changes to Image2 and when I move mouse away from the panel, it shows the defualt image (Image1). What I am going to do? Thanks, Visoth
-
private void panel1_MouseEnter(object sender, EventArgs e)
{
panel1.BackgroundImage = ...
}private void panel1_MouseLeave(object sender, EventArgs e)
{
panel1.BackgroundImage = ...
{A simple google search would of gave you the answer to this.
Firstly, I would like to thanks for your respond. When I mouse enter, it changes the backgroupimage but not the same image that I want it to show. The second thing is when i leave mouse away, it still catch the image that i use mouse enter. Please see my code below: private void panel5_MouseEnter(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Selected.bmp"]; } private void panel5_MouseLeave(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Unselected.bmp"]; } Thanks
-
Firstly, I would like to thanks for your respond. When I mouse enter, it changes the backgroupimage but not the same image that I want it to show. The second thing is when i leave mouse away, it still catch the image that i use mouse enter. Please see my code below: private void panel5_MouseEnter(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Selected.bmp"]; } private void panel5_MouseLeave(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Unselected.bmp"]; } Thanks
misCafe wrote:
private void panel5_MouseEnter(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Selected.bmp"]; } private void panel5_MouseLeave(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Unselected.bmp"]; }
This code should work according what you want. Double check the image list, and other code might affect the changes.
;)*12Code
-
misCafe wrote:
private void panel5_MouseEnter(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Selected.bmp"]; } private void panel5_MouseLeave(object sender, EventArgs e) { this.panel5.BackgroundImage = imageList1.Images["Selection Bar Unselected.bmp"]; }
This code should work according what you want. Double check the image list, and other code might affect the changes.
;)*12Code