Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I have application form with transparent picturebox....

so it show what is behind the form....

i want to know how to prevent this
Posted
Comments
Ebnezer Oyenuga 29-Dec-11 18:13pm    
try and give the picture box a background colour
elgammal 29-Dec-11 18:19pm    
I mean that this picturebox is transparent at run time not for design.....

Probably because the background color of the picture box is also specified as the transparent color of the form.

So ensure that the form do not specify a color to render as transparent.

If you do want irregular shaped windows and a picture box, then a color that does exist in the picture must be used for the transparency key of the form.

If need are more complex, you might have to uses multiple windows or WPF (or maybe use Windows API directly) as WinForms are somewhat limited in that area.
 
Share this answer
 
A transparent image (PNG 24 with transparency, Gif with transparency), in a PictureBox on a Form is going to show the Form's BackgroundColor in its transparent areas, and, if placed over other controls, like a TextBox, for example, the areas in your Image you may think are "transparent" will cover the other controls with the Form BackGroundColor.

The only way the transparent areas in the image will show what is "behind the Form" is if you have set a Transparency Key property for the Form itself with the same Color as the BackGround Color you have set for the PictureBox.

WinForms does not really support "true transparency" in the way WPF does, for example. There are lots of articles on the web showing various tricks to get different types of transparency into WinForms, ranging from using Custom Paint Events to using Panels with certain SetStyle options set. There are exotic solutions using transparent Form overlays, and special Windows API calls.

Check out, here on CP: [^].

imho, you are generally wasting time to try and get sophisticated transparency effects in WinForms.
 
Share this answer
 
Comments
elgammal 30-Dec-11 13:22pm    
I found the solution ,it is:
the transparency key of the form was white
and the picturebox was white
so it was transparent

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