开发者

How to highlight a control when selected?

How can I hig开发者_开发技巧hlight an image when it is clicked and remove the highlight when the mouse is up?


Two steps:

  1. 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;
  2. 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜