semi-transparent form but opaque Controls in C#

后端 未结 3 513
無奈伤痛
無奈伤痛 2020-12-16 22:09

How to make semi transparent form in C# windows form application

I have tried the TransparentKey which makes it full-transparent. and tried Opacit

3条回答
  •  既然无缘
    2020-12-16 22:47

    You can use a hatch brush with a certain percentage, for example:

        using System.Drawing.Drawing2D;
    
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            var hb = new HatchBrush(HatchStyle.Percent50, this.TransparencyKey);
    
            e.Graphics.FillRectangle(hb,this.DisplayRectangle);
        }
    

提交回复
热议问题