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?
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.
If using WinForms
then Setting the background color to transparent won't work as transparency handling is not a cascading system - you can only (in most cases) set transparency (or rather the opacity) of a control overall using the Opacity
property, however this will alter the alpha channel of the entire control display giving your images a see-througness.
One solution might be to set the background color of the PictureBox
to be that of the control beneath it (the color of the form, for example). But this may not suffice in your situation.
hi you must set the icon on the other portion underneath the icon by using this
icon_pictureBox_name.Controls.Add(other_portion_picturBox_name);
and after that you can set the PictureBox.BackColor property to "Transparent" and it will work ;)