Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

how can i do the

Hilight the Button control in mousehover event?

let me know


Thanks in advance......
Posted
Comments
Raje_ 7-Aug-12 0:59am    
you can do it easily by using JavaScript.
Prabhakaran Soundarapandian 7-Aug-12 1:00am    
Is that a web app or WPF or ..?

If you want to highlight button when mouse is on button and remove highlight effect when mouse is out of button then use below code

Declare button's Mouse_Enter & Mouse_Leave event

Inside Mouse_Enter event
C#
btn.BackColor = Color.Gold;//highlight


Inside Mouse_Leave event
C#
btn.BackColor = Color.Transparent;//remove highlight effect when mouse leaves button


Happy Coding!
:)
 
Share this answer
 
Comments
Raje_ 7-Aug-12 1:24am    
+5 for win app!
Aarti Meswania 7-Aug-12 1:28am    
thank you! :)
_Amy 7-Aug-12 1:29am    
My +5!
Aarti Meswania 7-Aug-12 1:30am    
thank you!:)
If you want to implement this in Web Application, then you can use Javascript and css for changing the background of button onmouseover.
this is your Javascript code:
JavaScript
function change(sender) {
           sender.style.background = "Black";
           sender.style.color = "white";
       }
       function changeback(sender) {
           sender.style.background = "white";
           sender.style.color = "black";
       }


Here is your css code:
CSS
#btnAll
  {
      background-color:white;
      color:black;
  }

And finally take a button:
ASP.NET
<asp:button id="btnAll" onmouseover="javascript:change(this)" onmouseout="javascript:changeback(this)" runat="server" text="Display All" />


Good luck.
 
Share this answer
 
v2
Comments
_Amy 7-Aug-12 1:25am    
Rajesh, The question in in WinForms. Read carefully. :)
Raje_ 7-Aug-12 1:31am    
O'ops!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900