我想制作一个我自己的按钮,里面有 2 个其他按钮,我想让它们透明,但透明度不起作用

I want to make a my own button which has 2 other button inside and I want to make them transparent but transparency doesn't work

我有一个按钮,我在里面放了另外两个按钮。我希望其他两个按钮仅在我用鼠标输入主按钮时出现。当我输入它时,我希望其他 2 个按钮是半不透明的,只有当我输入这 2 个按钮之一时才完全不透明。

这些按钮位于带有背景图像的 FlowLayoutPanel 中。 这是他们的样子:

按钮内部有图片和文字。

这是我的代码:

public class MyButton : Button
{
    public MyButton()
    {
        SetStyle(ControlStyles.StandardClick | 
                 ControlStyles.StandardDoubleClick, true);

        Text = component.ProductsName;
        TextAlign = ContentAlignment.TopCenter;
        ImageAlign = ContentAlignment.TopLeft;
        Size = new Size(178, 75);

        foreach (Button item in CustomButtons())
        {
            Controls.Add(item);
        }
    }

    static Button[] CustomButtons()
    {
        Button delete = new Button();
        delete.Location = new Point(157, 1);
        delete.Size = new Size(20, 20);
        delete.MouseEnter += OnMouseEnter;
        delete.MouseLeave += DeleteOnMouseLeave;

        Button customize = new Button();
        customize.Location = new Point(delete.Left - 20, 1);
        customize.Size = new Size(20, 20);

        Button[] buttons = {delete, customize};
        return buttons;
    }

    private static void DeleteOnMouseLeave(object sender, EventArgs e)
    {
        Button btn = (Button) sender;
        btn.UseVisualStyleBackColor = true;
        btn.BackColor = Color.Transparent;
    }

    private static void OnMouseEnter(object sender, EventArgs e)
    {
        Button btn = (Button) sender;
        btn.UseVisualStyleBackColor = false;
        btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(100, 
                                                       Color.Black);
    }
 }

我想我已经尝试了我想到的一切,我尝试了事件和一切,但按钮从来没有像我预期的那样工作。 任何帮助,将不胜感激!谢谢! :D

看来我解决了!我只需要设置 Flatstyle = FlatStyle.Flat 和 backColor = Color.Transparent! :D

结果如下:exsample of output