Transparent background on winforms?

前端 未结 9 2077
走了就别回头了
走了就别回头了 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:34

    I've tried the solutions above (and also) many other solutions from other posts.

    In my case, I did it with the following setup:

    public partial class WaitingDialog : Form
    {
        public WaitingDialog()
        {
            InitializeComponent();
    
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.Transparent;
    
            // Other stuff
        }
    
        protected override void OnPaintBackground(PaintEventArgs e) { /* Ignore */ }
    }
    

    As you can see, this is a mix of previously given answers.

提交回复
热议问题