[英]How do I change the color of a TLabel when my cursor hovers hover it in Delphi?
So I tried using the OnMouseEnter
event for the label and used the code:所以我尝试对标签使用
OnMouseEnter
事件并使用代码:
Label1.Color := clPurple;
But that didn't work但这没有用
You need to set the Transparent property to FALSE
.您需要将 Transparent 属性设置为
FALSE
。
Also, don't forget you need to set the OnMouseExit
event too.另外,不要忘记您也需要设置
OnMouseExit
事件。
So the simplest way is to set the color property in the designer, then set the transparent property to FALSE
in the OnMouseEnter
event and TRUE
in the OnMouseExit
event.所以,最简单的办法是设置颜色属性在设计师,然后设置透明属性为
FALSE
在OnMouseEnter
事件和TRUE
在OnMouseExit
事件。
Label1.Font.Color := clPurple;
Label1.Color
是透明的背景色。
The label can't be transparent to do this in the event and labels are transparent by default, so do this:在事件中标签不能透明,标签默认是透明的,所以这样做:
Label1.Color := clPurple;
Label1.Transparent := False
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.