按钮WinForms的70%不透明度颜色

时间:2016-12-17 22:50:52

标签: c# winforms

当我将鼠标悬停在仍然像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;
        }

  在这里,我将鼠标移开并按下按钮,这样你就可以看到我拥有的东西了。 编辑:解决了....现在上面的代码正是我想要的。

1 个答案:

答案 0 :(得分:1)

问题解决了。我更改了代码如下:

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