How can I hig开发者_开发技巧hlight an image when it is clicked and remove the highlight when the mouse is up?
Two steps:
- Capture Control.MouseDown Event
- Get the current color in OldColor
- Set the new color; and it would reflect the colored control.
- Something like
button1.BackColor = Color.Red;
- Capture the Control.MouseUp Event
- Set the OldColor
Look at this highlight color on button click i think it deals with your problem
Why don't you go for CSS psuedo classes(:active,:hover), please take a look at this code.
<div class="rollover">
<a href="#"><img src="Jpeg/image.gif" /></a>
</div>
<style type="text/css">
<!--
.rollover a { display:block; width:32px; background-color: #FFFFFF}
.rollover a:hover { background-color: #990000}
.rollover a:active { background-color: #876787}
-->
</style>
精彩评论