[C#]如果formis半透明,如何使标签背景透明?

编程入门 行业动态 更新时间:2024-10-28 00:23:02
本文介绍了[C#]如果formis半透明,如何使标签背景透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的问题是我使用此代码的半透明表单:

My problem is that I have a semi transparent form using this code:

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

我希望在该表单上有一个与表单本身具有相同半透明背景的标签。我试了很多东西,但标签一直呈黑色。解决方案是什么?

and I want to have a label on that form that has a the same semi transparent background as the form itself. I tried multiple things but the label appears pitch black all the time. What is the solution to this?

谢谢

推荐答案

您好Siratox,

Hi Siratox,

正如Castorix31所说,您可以尝试将表单的不透明度设置为"0.5":

Just as Castorix31 said, you can try to set the form's Opacity to "0.5":

private void Form1_Load(object sender, EventArgs e) { this.Opacity = 0.5; }

通过这种方式,标签将具有相同的透明度。

In this way, the label will have the same transparency.

问候,

Kyle

更多推荐

[C#]如果formis半透明,如何使标签背景透明?

本文发布于:2023-11-04 05:55:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557131.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:透明   背景   标签   formis

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!