我创建了一个标签,如果触发某个事件,则需要以编程方式将其颜色更改为特定的 RGB 颜色代码。
我是这样试过的:
statusStripTestLabel.ForeColor = new Color(128, 64, 64);
奖金:
Set it to a RGBA color.
但我得到Color does not have a constructor which accepts 3 arguments.
那么我该如何解决这个问题呢?
statusStripTestLabel.ForeColor = Color.FromArgb(128, 64, 64); //Alpha is implicitly 255.
statusStripTestLabel.ForeColor = Color.FromArgb(255, 128, 64, 64); //Alpha is explicitly 255. You can change the value of the first parameter to specify the alpha you want.
你正在尝试的在 JAVA 中有点正确。 在 C# 中是,
您的组件。前色=颜色。来自阿格布(theARGB_Code( ;
*请注意,并非所有组件都支持透明度