Transparent background on winforms?

前端 未结 9 2079
走了就别回头了
走了就别回头了 2020-11-29 03:39

I wanted to make my windows form transparent so removed the borders, controls and everything leaving only the forms box, then I tried to the BackColor and TransparencyKey to

9条回答
  •  温柔的废话
    2020-11-29 04:35

    I had drawn a splash screen (32bpp BGRA) with "transparent" background color in VS2013 and put a pictureBox in a form for display. For me a combination of above answers worked:

    public Form1()
    {
        InitializeComponent();
    
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        this.BackColor = this.pictureBox1.BackColor;
        this.TransparencyKey = this.pictureBox1.BackColor;
    }
    

    So make sure you use the same BackColor everywhere and set that color as the TransparencyKey.

提交回复
热议问题