在鼠标悬停事件中使Button控件高亮显示 [英] Hilight the Button control in mousehover event
本文介绍了在鼠标悬停事件中使Button控件高亮显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我该怎么办
鼠标悬停事件中的Button控件处于高亮状态?
让我知道
在此先感谢......
hi all,
how can i do the
Hilight the Button control in mousehover event?
let me know
Thanks in advance......
推荐答案
如果要在鼠标位于按钮上时突出显示按钮,而在鼠标不在按钮上时删除突出显示效果,请在下面使用代码
声明按钮的Mouse_Enter& Mouse_Leave事件
内部Mouse_Enter事件
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
btn.BackColor = Color.Gold;//highlight
内部Mouse_Leave事件
Inside Mouse_Leave event
btn.BackColor = Color.Transparent;//remove highlight effect when mouse leaves button
祝您编码愉快!
:)
Happy Coding!
:)
如果要在Web应用程序中实现此功能,则可以使用Javascript和CSS更改按钮onmouseover的背景.
这是您的Javascript代码:
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:
function change(sender) {
sender.style.background = "Black";
sender.style.color = "white";
}
function changeback(sender) {
sender.style.background = "white";
sender.style.color = "black";
}
这是您的CSS代码:
Here is your css code:
#btnAll
{
background-color:white;
color:black;
}
最后按下一个按钮:
And finally take a button:
<asp:button id="btnAll" onmouseover="javascript:change(this)" onmouseout="javascript:changeback(this)" runat="server" text="Display All" />
祝你好运.
Good luck.
请参考以下链接:
WinForms VB.NET图片悬停按钮 [> http://stackoverflow.com/questions/2554241/how-to- change-button-background-image-on-mouseover [ ^ ]
--Amit
Hi,
Refer the links below:
WinForms VB.NET Picture Hover Button[^]
http://stackoverflow.com/questions/2554241/how-to-change-button-background-image-on-mouseover[^]
--Amit
这篇关于在鼠标悬停事件中使Button控件高亮显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文