Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 请告诉我如何使label1背景透明?_C# - Fatal编程技术网

C# 请告诉我如何使label1背景透明?

C# 请告诉我如何使label1背景透明?,c#,C#,请告诉我如何使label1背景透明 这是行不通的 label1.BackColor = Color.Transparent; 属性的使用应该是正确的,但是您还需要确保所使用的特定控件已启用对透明背景的支持,如文档中所述: BackColor属性不支持透明颜色,除非System.Windows.Forms.ControlStyles的SupportsTransparentBackColor值设置为true 默认情况下,标签将提取其容器的背景色,因此,如果它只是直接位于表单上,您应该能够使用: p

请告诉我如何使label1背景透明

这是行不通的

label1.BackColor = Color.Transparent;
属性的使用应该是正确的,但是您还需要确保所使用的特定控件已启用对透明背景的支持,如文档中所述:

BackColor属性不支持透明颜色,除非System.Windows.Forms.ControlStyles的
SupportsTransparentBackColor
值设置为true

默认情况下,标签将提取其容器的背景色,因此,如果它只是直接位于表单上,您应该能够使用:

public Form1()
{
        InitializeComponent();
        // Indicate this form would explicitly support transparency
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        BackColor = Color.Transparent;
        // Make your label transparent
        label1.BackColor = Color.Transparent;
}
否则,您需要确保它的容器元素支持透明并且是透明的。

属性的使用应该是正确的,但是您还需要确保您使用的特定控件已启用对透明背景的支持,如文档中所述:

BackColor属性不支持透明颜色,除非System.Windows.Forms.ControlStyles的
SupportsTransparentBackColor
值设置为true

默认情况下,标签将提取其容器的背景色,因此,如果它只是直接位于表单上,您应该能够使用:

public Form1()
{
        InitializeComponent();
        // Indicate this form would explicitly support transparency
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        BackColor = Color.Transparent;
        // Make your label transparent
        label1.BackColor = Color.Transparent;
}

否则,您需要确保它的容器元素支持透明度并且是透明的。

请参见:谢谢,但这不是您需要的信息。我认为这正是您需要的。但请注意:“Windows窗体控件不支持真正的透明度。透明Windows窗体控件的背景由其父控件绘制。”这不起作用。是的。但您需要确保它嵌套在另一个控件中;对于某些控件,如PictureBox,这必须在代码中完成:
label.Parent=PictureBox
请参见:谢谢,但不是这些信息。我认为这正是您需要的。但请注意:“Windows窗体控件不支持真正的透明度。透明Windows窗体控件的背景由其父控件绘制。”这不起作用。是的。但您需要确保它嵌套在另一个控件中;对于某些控件,如PictureBox,这必须在代码中完成:
label.Parent=PictureBox
就是这样!正是我的意思,就是这样!正是我的意思。