我想在我将鼠标悬停在按钮上时仍然保持 30% 透明(这样您可以从表单中看到背景图像)但仍然看到一些颜色时产生这种效果..
我试过了,但这只是给我一片空白:
private void roundedButton2_MouseEnter(object sender, EventArgs e)
{
roundedButton2.UseVisualStyleBackColor = false;
roundedButton2.FlatAppearance.MouseOverBackColor = Color.FromArgb(100, Color.Black);
}
private void roundedButton2_MouseLeave(object sender, EventArgs e)
{
roundedButton2.UseVisualStyleBackColor = true;
roundedButton2.BackColor = Color.Transparent;
}
在这里,我将鼠标移出并将鼠标放在按钮上,这样您就可以看到我拥有的东西。 编辑:解决了....现在上面的代码完全符合我的要求。
最佳答案
问题解决了。我将代码更改如下:
private void roundedButton2_MouseEnter(object sender, EventArgs e)
{
roundedButton2.UseVisualStyleBackColor = false;
roundedButton2.FlatAppearance.MouseOverBackColor = Color.FromArgb(100, Color.Black);
}
private void roundedButton2_MouseLeave(object sender, EventArgs e)
{
roundedButton2.UseVisualStyleBackColor = true;
roundedButton2.BackColor = Color.Transparent;
}
必须在背景色之前添加 FlatAppearance。
关于c# - 按钮 WinForms 的 70% 不透明度颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41203825/