当我将鼠标悬停在仍然像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;
}
不得不在backcolor之前添加FlatAppearance.