I want to add a label to my form , and I want it without any color- I want just it's text to be visible, I don't find this option in the label's properties, can anyone help me please?
-
1Rather than the nonsense of `Color.Transparent`, might I humbly suggest you set the label's background to the same color as its container (the form, most likely)? Say, `SystemColors.Control`? – Cody Gray - on strike Jan 09 '11 at 14:29
-
This will only work if the parent has one color only. – TaW Aug 29 '21 at 04:22
10 Answers
Do you want to make the label (except for the text) transparent? Windows Forms (I assume WinForms - is this true) doesn't really support transparency. The easiest way, sometimes, is Label's Backcolor to Transparent.
label1.BackColor = System.Drawing.Color.Transparent;
You will run into problems though, as WinForms really doesn't properly support transparency. Otherwise, see here:
http://www.doogal.co.uk/transparent.php
http://www.codeproject.com/KB/dotnet/transparent_controls_net.aspx
http://www.daniweb.com/code/snippet216425.html
Setting the parent of a usercontrol prevents it from being transparent
Good luck!
-
14Setting to "Transparent" doesn't work if the label overlaps something. (I wanted transparency because of overlap and just tried this. It didn't work.) – Eponymous Feb 10 '14 at 03:18
-
1This is working for me (a label over PictureBox): http://stackoverflow.com/questions/9387267/transparent-control-over-picturebox – Taras Kozubski Dec 10 '15 at 08:22
-
6You have to set the label's Parent property to the object you're overlapping. At least if that object is a PictureBox; not sure about other controls. Try it and see. – Toolsmythe Jul 24 '18 at 00:23
-
-
If you picture box in the background then use this:
label1.Parent = pictureBox1;
label1.BackColor = Color.Transparent;
Put this code below InitializeComponent();
or in Form_Load
Method.
Ref: https://www.c-sharpcorner.com/blogs/how-to-make-a-transparent-label-over-a-picturebox1

- 2,215
- 19
- 16
-
1Notice as you change parent the .Top and .Left of the label need adjustment by distance between upper left corners of the parent controls. You can transfer current label position into screen coordinates and then have the new parent translate it back to local coordinates. Before assigning new parent pictureBox1 do: lbl1.Location = pictureBox1.PointToClient(lbl1.Parent.PointToScreen(lbl1.Location)); – flodis Dec 19 '20 at 14:53
-
@flodis thanks for your comment. That was indeed the final nail in the coffin that solved the issue. – Eyal Gerber Nov 17 '21 at 13:54
-
You are right. but here is the simplest way for making the back color of the label transparent In the properties window of that label select Web.. In Web select Transparent :)

- 39
- 1
-
if you put 2 labels close to each other - that will not work – Gorodeckij Dimitrij May 07 '22 at 19:39
this.label1.BackColor = System.Drawing.Color.Transparent;

- 5,528
- 7
- 37
- 52
-
1Good luck on expecting WinForms to handle transparencies properly ;) It is the same issue with WinForms Aero. – Machinarius Jan 09 '11 at 13:54
-
6@Drknezz yeah, they shouldn't call something "transparent" that actually means "inherit the background color of the parent"... :) – Roman Starkov Jan 09 '11 at 13:59
-
@Drknezz: What is "WinForms Aero"? Is that what the cool kids are calling WPF nowadays? – Cody Gray - on strike Jan 09 '11 at 14:29
-
1@Cody WPF isnt just thew kid on the block, it eases development a lot and integrates a lot more HW-Accelerated features than WinForms, Check it out. [BTW: Have you been hiding on a cave or sth?] @Romkyns +1 XD – Machinarius Jan 09 '11 at 15:55
-
@Drknezz: I know full well what WPF is, thank you. I've just never heard of "WinForms Aero", probably because it doesn't exist. I wasn't calling WPF the new kid on the block, I was asking if that's what you're calling "WinForms Aero". – Cody Gray - on strike Jan 09 '11 at 16:02
-
2@Cody I was referring to getting the Aero glass sheet effect on WinForms :p – Machinarius Jan 09 '11 at 16:04
Let's view 2 possible cases.
- Background is a color. Double-Click the form background in VS constructor. Then, write this code:
/*
This code will set all your object's background color to the same as the form.
This should be written in the body of <FormName>_Load(object, EventArgs).
*/
Control[] objs = new Control[] { /* your object list, e. g { myLabel, myPicture } */ };
foreach (Control control in objs) {
control.BackColor = Color.Transparent;
// OR
control.BackColor = this.BackColor;
}
- Background is a PictureBox. This is also easy. We just need to make all objects as children of your PictureBox and set it's color to transparent. Code:
/*
This code will set all your object's background to transparent and show the PBox.
This should be written in the body of <FormName>_Load(object, EventArgs)'s foreach loop.
Put everything before it the same as in 1st code fragment.
*/
control.Parent = back;
control.BackColor = Color.Transparent;
Let's see the pictures.

- 25
- 1
- 8
Generally, labels and textboxes that appear in front of an image is best organized in a panel. When rendering, if labels need to be transparent to an image within the panel, you can switch to image as parent of labels in Form initiation like this:
var oldParent = panel1;
var newParent = pictureBox1;
foreach (var label in oldParent.Controls.OfType<Label>())
{
label.Location = newParent.PointToClient(label.Parent.PointToScreen(label.Location));
label.Parent = newParent;
label.BackColor = Color.Transparent;
}

- 1,123
- 13
- 9
This uses Graphics.CopyFromScreen so the control needs to be added when it's visable on screen.
public partial class TransparentLabelControl : Label
{
public TransparentLabelControl()
{
this.AutoSize = true;
this.Visible = false;
this.ImageAlign = ContentAlignment.TopLeft;
this.Visible = true;
this.Resize += TransparentLabelControl_Resize;
this.LocationChanged += TransparentLabelControl_LocationChanged;
this.TextChanged += TransparentLabelControl_TextChanged;
this.ParentChanged += TransparentLabelControl_ParentChanged;
}
#region Events
private void TransparentLabelControl_ParentChanged(object sender, EventArgs e)
{
SetTransparent();
if (this.Parent != null)
{
this.Parent.ControlAdded += Parent_ControlAdded;
this.Parent.ControlRemoved += Parent_ControlRemoved;
}
}
private void Parent_ControlRemoved(object sender, ControlEventArgs e)
{
SetTransparent();
}
private void Parent_ControlAdded(object sender, ControlEventArgs e)
{
if (this.Bounds.IntersectsWith(e.Control.Bounds))
{
SetTransparent();
}
}
private void TransparentLabelControl_TextChanged(object sender, EventArgs e)
{
SetTransparent();
}
private void TransparentLabelControl_LocationChanged(object sender, EventArgs e)
{
SetTransparent();
}
private void TransparentLabelControl_Resize(object sender, EventArgs e)
{
SetTransparent();
}
#endregion
public void SetTransparent()
{
if (this.Parent!= null)
{
this.Visible = false;
this.Image = this.takeComponentScreenShot(this.Parent);
this.Visible = true;
}
}
private Bitmap takeComponentScreenShot(Control control)
{
Rectangle rect = control.RectangleToScreen(this.Bounds);
if (rect.Width == 0 || rect.Height == 0)
{
return null;
}
Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
return bmp;
}
}

- 11
- 3
An easy way to have a label with a picture behind it is to use the Image Property of the label itself. This will print the text over the top of the picture, and enable you to align the image (top/bottom/left/right/centre) as required.picture

- 163
- 2
- 9
-
Hi @Daniel-Barnes can you add some code examples to this explain, just to make it clear. – Pimenta Aug 31 '21 at 11:21
-
1Hi @Pimenta, no code required, It is done with the Properties section in the Visual Studio designer. I have attached a picture, as I am new I can only attach the picture as a link. – Daniel Barnes Sep 02 '21 at 00:03
I just want to add my findings for VS2022,
In VS 2022,.NET 6.0 or 7.0 below code does work.
I do see some comments above that this was not working but I guess Microsoft has addressed it in newer versions.
label1.BackColor = System.Drawing.Color.Transparent;

- 2,363
- 3
- 34
- 64