cap1 Hi, I'm trying to build a simulation environment where male and female individuals move randomly in a map, which have one picturebox and one label each.
My problem is, I can't seem to make them transparent (see the picture attached)
Person.cs:

this.label.BackColor = Color.Transparent
this.picturebox.BackColor = Color.Transparent

does not work.
Also, the png images are transparent outside of the circles.

How can I make the pictureboxes and labels completely transparent?
Thanks for help!

Hi staticclass,

And welcome to the irritating world of trying to use transparency in WinForms!

This may seem counter-intuitive, but instead of using the PictureBox Control, try using a Panel instead.

Place your image as the BackgroundImage. Use the BackgroundImageLayout property as you would the PictureBox SizeMode Property.

This will give you the ability to place labels using the Transparent BackColor as well as other panels with Transparent BackColor and get the transparent effect.

The only thing that you loose using this method is the ability to use animated Gifs. You can still use them as a picture, but they will not animate.

This will not be a perfect solution, as controls do not support true transparency. It is simulated by the controls parent drwing the background. You will see the inconsistancy when two of you png images or labels overlap.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.