Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
I have png images without background but in my pictureboxes backgrounds are white i tryed to set BackColor to Transparent but it didn't work.
Can u say me how i can get transparent bacground in PictureBox?
Posted
Updated 12-Mar-20 2:05am
Comments
Sergey Alexandrovich Kryukov 23-Feb-12 22:56pm    
Not clear. Why do you use PictireBox? Any benefits? Why setting BackColor to transparent? Did you really preserve transparency in PNG? How about a code sample?
--SA
Ankit Kumar Gupta 23-Feb-12 23:23pm    
Not Clear. If transparency is preserved in PNG, then it will not show white background. Hence, Code sample and the image used is required.

Follow three steps process to set the transparent color.

Step 1: Locate the constructor for your control class.

Step 2: In the constructor, call the SetStyle method of your form. This will enable your control to support a transparent backcolor.
C#
SetStyle(ControlStyles.SupportsTransparentBackColor, true);


Step 3: After the line of code you added in the previous step, set your control's BackColor to Transparent.
C#
this.BackColor = Color.Transparent;
 
Share this answer
 
Do This,

Set the backcolor of PictureBox to be same as the backcolor of the form on which it is.

Eg. if

C#
this.BackColor= Color.Blue;
pictureBox1.BackColor = Color.Blue;


Also try doing it once with some other image which has true transparency. Maybe your image does not have transparency!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900