简体   繁体   English

当我的光标悬停在 Delphi 中时,如何更改 TLabel 的颜色?

[英]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.所以,最简单的办法是设置颜色属性在设计师,然后设置透明属性为FALSEOnMouseEnter事件和TRUEOnMouseExit事件。

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.

相关问题 如何让TLabel在Delphi中表现得像超链接? - How do I make a TLabel behave like a hyperlink in Delphi? 当我的 cursor 结束时,如何放大 Delphi 中的 TImage? - How do I enlarge a TImage in Delphi when my cursor is over it? 如何在Delphi的菜单栏中添加TLabel? - How Do I Add A TLabel To The Menu Bar in Delphi? 如何在Delphi中更改滚动条的颜色? - How do I change the color of a scrollbar in Delphi? 在 delphi firemonkey 我如何使用 TLabel 来显示日期和时间 - In delphi firemonkey how can i use a TLabel to display date and time Delphi7如何更改按钮的颜色及其标题? - Delphi7 How do I change the color of a button and its caption? 如何更改我在 Delphi 文件中输入的线条的颜色,所以当我稍后将其可视化时,不同类型的线条具有不同的颜色 - How do I change the color of the line I enter in a Delphi file, so when I visualize it later different type of lines have different color 如何在覆盖模式下更改Delphi的光标形状? - How can I change Delphi's cursor shape when it's in overwrite mode? 当鼠标悬停在Delphi上时如何突出显示标签? - How to highlight a label in Delphi when the mouse hovers over it? 如何以编程方式更改 Tlabel 的 FontColor - How to programmatically change the FontColor of a Tlabel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM