Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a transparent background on a PictureBox in WinForms?

I want to make the background of a PictureBox control transparent. In the PictureBox (rectangular shape), I placed an icon (circular in shape). I want to make the icon transparent so that the other portion underneath the icon is visible.

I have tried setting the PictureBox.BackColor property to "Transparent", but it doesn't work. I also tried to set it during runtime with the Color.FromArgb method, but it doesn't work either.

Is there any solution to this problem?

like image 481
Khalad Avatar asked Feb 13 '11 11:02

Khalad


1 Answers

Setting pictureBox.BackColor = Color.Transparent; definitely should work.

Also verify if you are setting alpha channel of color when using Color.FromArgb(0, 0, 0, 0); (this is a first parameter, zero means transparent color)

And, of course, make sure your icons have transparent background.

like image 148
Sergey Berezovskiy Avatar answered Oct 19 '22 03:10

Sergey Berezovskiy