Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
o.k guys, the problem today goes like this:
I have an MDI form which contains all the other forms obviously.
on the main menu of my program (on the MDI form), i want to lay 4 pictureBox's.
Now, the BackgroundImage of the mdi is NOT set to none and i am loading my own picture and stretch it. the picturebox backColor is set to Transparent. when i run the code, instead of transparent Background on the pictureBox where i can see the BackgroundImage of the mdi, all i can see is white Background (or Gray). any ideas?

1 solution

I guess this is about understanding or "transparency". In raw effect, nothing is transparent: you just have different colors for different pixels, and the pixel is always 100% opaque.
The effect of transparency comes up (rather as a metaphor), when you move some object over non-uniform background. Then the background behave as some see-through pattern; the resulting pixels are composed of the combination of colors of background and foreground. On a uniform background, "transparency" is undetectable. There is no a way to spot the difference between the semi-transparent image, or some 100% opaque image tinted with the background color in certain proportion depending on some opaqueness value.

Now: two recommendations which may come at surprise:
  • Almost never use PictureBox. This control is totally redundant and won't give you any benefits (but may add a lot of troubles), except the simplest possible cases. Transparency is already not the simple case. Instead, render some Image on some Control yourself. Showing some semi-transparent image is quite trivial.

  • Never use MDI. Don't torture yourself and scare off you customers. You will see what I recommend to do in some of the past answers referenced below.

Some references to my past answers:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
capture the drawing on a panel[^],
Drawing Lines between mdi child forms[^],
How to Create MDI Parent Window in WPF? [Solution 2],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

Good luck.
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