0

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!

Edited by staticclass: forgot the picture

Attachments cap.png 12.56 KB
2
Contributors
1
Reply
4
Views
5 Years
Discussion Span
Last Post by TnTinMN
0

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.

Edited by TnTinMN

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.