如何在 VB.NET 中制作带有透明背景色的标签?文本与其他内容重叠
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26372806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make a Label with Transparent BackColor in VB.NET? The text overlaps with something else
提问by Edmo Cavalcante
When I use LabelAngle(i).BackColor = Color.Transparentsomething else show up.
当我使用LabelAngle(i).BackColor = Color.Transparent 时,会出现其他东西。
![LabelAngle(i).BackColor = Color.Transparent][1]
![LabelAngle(i).BackColor = Color.Transparent][1]
LabelAngle(i) = New Label
LabelAngle(i).Parent = canvas
LabelAngle(i).AutoSize = True
LabelAngle(i).ForeColor = System.Drawing.Color.DodgerBlue
LabelAngle(i).Location = New System.Drawing.Point(Xstart(i) - 30, ReferenceY - BarHeight)
LabelAngleValue(i) = 180 - randAngle(i)
LabelAngle(i).Text = LabelAngleValue(i).ToString + "°"
LabelAngle(i).TextAlign = ContentAlignment.BottomLeft
LabelAngle(i).BackColor = Color.Transparent
LabelAngle(i).BringToFront()
回答by Creator
To make a label transparent you need to set the forms transparencykey to lets say maroon "or a color you never will use".
要使标签透明,您需要将表单透明键设置为栗色“或您永远不会使用的颜色”。
Then if you set the label Backcolor to Maroon it will be transparent.
然后,如果您将标签背景色设置为栗色,它将是透明的。
"But it will never show the control under it"
“但它永远不会显示它的控制”
回答by betrice mpalanzi
Just type the colour code 16777215
into the BackColour property
只需16777215
在 BackColour 属性中输入颜色代码