简体   繁体   English

如何使用 rgb 值更改 label 的背面颜色

[英]How to change back color of a label using rgb values

I want to change the back color of a label using RGB values.我想使用 RGB 值更改 label 的背景颜色。 I can't figure out how?我想不通怎么办?

I want to change the back color from 30, 30, 30 to 36, 36, 36 on hover and back to 30, 30, 30 when mouse stops hovering.我想在 hover 上将背景颜色从30、30、30更改为36、36、36 并在鼠标停止悬停时更改为 30、30、30。

Based on your question, I'm assuming you mean when the mouse enters and leaves the WinForm label's region, as per John's comment.根据您的问题,我假设您的意思是鼠标进入和离开 WinForm 标签区域时,根据约翰的评论。 To do this, you would need to hook the label's MouseEnter and MouseLeave events.为此,您需要挂钩标签的 MouseEnter 和 MouseLeave 事件。 Below, I have assumes the label's name is "label1"下面,我假设标签的名称是“label1”

private void label1_MouseEnter(object sender, EventArgs e)
{
    label1.BackColor = Color.FromArgb(36, 36, 36);
}

private void label1_MouseLeave(object sender, EventArgs e)
{
    label1.BackColor = Color.FromArgb(30, 30, 30);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM