本文介绍了[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?
谢谢
推荐答案
正如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半透明,如何使标签背景透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!