Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change image by MouseHover Event

Status
Not open for further replies.

nguyentaiuyenchi

Technical User
Nov 5, 2001
39
VN
- I built a custom control for command button like XP style.
- I want to change the image when mouse hover on it.
- The code is below:
---------------------------------------------
...
private enum MouseState
{defaultState,disableState,hoverState,normalState,pressedState}
private void ChangeImage(MouseState eState)
{
imgLeft.Image=imgListLeft.Images[(int)eState];
imgRight.Image=imgListRight.Images[(int)eState];
background.BackgroundImage=imgListBckg.Images[(int)eState];
}

private void XPButton_MouseHover(object sender, System.EventArgs e)
{
ChangeImage(MouseState.hoverState);
this.Refresh();
}

private void XPButton_Load(object sender, System.EventArgs e)
{
ChangeImage(MouseState.normalState);
}
...
-------------------------------------------

- However it seem does not work for hover event (only correct for Load event). Please tell me the way to do that.

Thank so much


Uyen Chi
Software developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top