C# transparent background for window form

前端 未结 4 1376
野趣味
野趣味 2021-01-12 15:40

I\'ve already seen Transparent background on winforms?

it doesnt offer solution to my problem. I am using the same method to try to achieve transparency



        
4条回答
  •  误落风尘
    2021-01-12 16:34

    This is the best way to make the transparent background of winform.

    right after this:

    public partial class frmTransparentBackcolor : Form
    {
        public frmTransparentBackcolor()
        {
            InitializeComponent();
            //set the backcolor and transparencykey on same color.
            this.BackColor = Color.LimeGreen;
            this.TransparencyKey = Color.LimeGreen;
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            e.Graphics.FillRectangle(Brushes.LimeGreen, e.ClipRectangle);
        }
    }
    

    hope this will help.

提交回复
热议问题