semi-transparent form but opaque Controls in C#

后端 未结 3 502
無奈伤痛
無奈伤痛 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:35

    I found the Hatch Brush grotesque,

    Instead of:

    protected override void OnPaintBackground(PaintEventArgs e) {
      var hb = new HatchBrush(HatchStyle.Percent80, this.TransparencyKey);
      e.Graphics.FillRectangle(hb, this.DisplayRectangle);
    }
    

    I used:

    protected override void OnPaintBackground(PaintEventArgs e) {
      var sb = new SolidBrush(Color.FromArgb(100, 100, 100, 100));
      e.Graphics.FillRectangle(sb, this.DisplayRectangle);
    }
    

提交回复
热议问题