Click here to Skip to main content
15,849,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a user control which background color is black and there 3 images.
1st one is on entire usercontrol and 2nd one is bottom part of usercontrol and last one is on second image with transperent background it is .png image but now when i set background transprent for it it always shows black
can any one tell me how to set it to black??
Posted
Comments
Sergey Alexandrovich Kryukov 14-Apr-13 2:50am    
PictureBox suggests it's System.Windows.Forms. Please tag "WinForms".
—SA

1 solution

If it is transparent, it's not really black. :-)

If you think what is transparency, you will understand that this concept is a kind of metaphor. It only makes sense if you have something to show under a "transparent" graphics. Moreover, it has strict sense only if there is some motion. You move top object and observe the objects underneath. You need to think if you want a form to be transparent, and see the windows of the different applications under it.

That said, you should understand that transparency of control is not well supported by System.Windows.Forms. If you need something flexible and advanced, switch to WPF, don't waste time of Forms, or give it up. If you have something limited, think about rendering of GDI objects in one custom control; this will work perfectly. And of course, don't even think about using PictureBox; it makes no sense at all. Please see some of my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^];
see also:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
How to speed up my vb.net application?[^].

—SA
 
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