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

Khalad picture Khalad · Feb 13, 2011 · Viewed 15.7k times · Source

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?

Answer

Sergey Berezovskiy picture Sergey Berezovskiy · Feb 13, 2011

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.