在C#中如何使Label背景透明? lblPstart.BackColor=Color.Transparent;这条语句用了背景还是不能透明。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我用:this.label1.BackColor = System.Drawing.Color.Transparent;可以透明啊! 在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true); 在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);这么做是使窗体可以使用透明色。 你的控件放在哪了,后面有没有picturebox 使用lblPstart.BackColor=Color.Transparent;可以让lable控件的背景色透明,可以看到摆放lable容器的背景色,但这个背景色不一定是窗体的背景色。比如:From1.Controls.Add(lable1);lable1.BackColor=Color.Transparent;这样,lable1就是透明的但是如果是:From1.Contorls.Add(pictureBox1);//或者是其它容器控件pictureBox1.Controls.Add(lable1);lable1.BackColor=Color.Transparent;那结果是lable1还是透明,但是看到的颜色是它的容器控件也就是pictureBox1的背景色,而不是窗体Form1的背景色。上面的代码可以在#region Windows 窗体设计器生成的代码/// <summary>/// 设计器支持所需的方法 - 不要使用代码编辑器修改/// 此方法的内容。/// </summary>private void InitializeComponent()方法中查看 在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);这么做是使窗体可以使用透明色。在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);这么做是使窗体可以使用透明色。在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);这么做是使窗体可以使用透明色。在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);这么做是使窗体可以使用透明色。在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);这么做是使窗体可以使用透明色。 我是放在一个Panel控件上的,这个控件是用来绘图的,但是不能透明。 我说的不能透明指得是label后面还有四方的灰色背景,楼上的兄弟们提供的方法等下实验 1.<asp:label Id="label1" BackColor="Transparent">2.this.label1.BackColor = System.Drawing.Color.Transparent;3.在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true); silverseven7() ( ) 在窗体的Load事件中加上这句代码试试看SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);这么做是使窗体可以使用透明色。--------------不行,不行,不行,不行,不行,不行,不行,不行,不行,不行, 有没有写在:InitializeComponent()里. public class myLabel : Label{ protected override void InitLayout() { base.InitLayout (); SetLabelTransparence(); } private void SetLabelTransparence() { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddString(this.Text, this.Font.FontFamily, (int)(FontStyle.Bold), this.Font.Size, new Point(this.ClientRectangle.Left,this.ClientRectangle.Top), new StringFormat()); this.BackColor = this.ForeColor; this.Region = new Region(path); }} 最好还是用GDI+绘制,label不可能透明,因为label也是绘制的,只是它是直接绘制在背景上。所以背景和文字无法分离开。最好就是直接在panel上绘制。 如果你只是想要显示一些动态文字,你可以用picturebox代替,将picturebox设成透明 private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { this.label1.BackColor = Color.Transparent; this.pictureBox1.Controls.Add(this.label1); }测试过没问题 把label的backColor的属性改成web中的Transparent。我就是这么弄的 post 接收参数问题 高手看下 winform和服务的交互。 winform 利用html现实界面内容问题 用过webchart的请指点迷经 C# 如何实现这种图片效果 请教,自定义NameSpace和菜单标签的问题 求助:关于WebClient类 高分求解动态弹出窗体的问题。 基于.net框架的应用程序运行速度问题!请高手指教。 原来在vb中,我们可以调用Windows API来往菜单上画图标,在.net不借用第3方控件怎样才能画出图标? 安装VS2005出现一个文件错误,那位安装过的兄弟帮忙给传一下这个文件!接分了! 如何清除画上去的图像?
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
这么做是使窗体可以使用透明色。
比如:
From1.Controls.Add(lable1);
lable1.BackColor=Color.Transparent;
这样,lable1就是透明的
但是如果是:
From1.Contorls.Add(pictureBox1);//或者是其它容器控件
pictureBox1.Controls.Add(lable1);
lable1.BackColor=Color.Transparent;
那结果是lable1还是透明,但是看到的颜色是它的容器控件也就是pictureBox1的背景色,而不是窗体Form1的背景色。
上面的代码可以在
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
方法中查看
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
这么做是使窗体可以使用透明色。
在窗体的Load事件中加上这句代码试试看
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
这么做是使窗体可以使用透明色。
在窗体的Load事件中加上这句代码试试看
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
这么做是使窗体可以使用透明色。
在窗体的Load事件中加上这句代码试试看
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
这么做是使窗体可以使用透明色。
在窗体的Load事件中加上这句代码试试看
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
这么做是使窗体可以使用透明色。
2.this.label1.BackColor = System.Drawing.Color.Transparent;
3.在窗体的Load事件中加上这句代码试试看
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
在窗体的Load事件中加上这句代码试试看
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
这么做是使窗体可以使用透明色。
--------------
不行,不行,不行,不行,不行,不行,不行,不行,不行,不行,
InitializeComponent()里.
{
protected override void InitLayout()
{
base.InitLayout ();
SetLabelTransparence();
}
private void SetLabelTransparence()
{
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddString(this.Text,
this.Font.FontFamily,
(int)(FontStyle.Bold),
this.Font.Size,
new Point(this.ClientRectangle.Left,this.ClientRectangle.Top),
new StringFormat());
this.BackColor = this.ForeColor;
this.Region = new Region(path);
}
}
{
this.label1.BackColor = Color.Transparent;
this.pictureBox1.Controls.Add(this.label1);
}
测试过没问题
我就是这么弄的