Reputation: 452
I have an array of picture boxes that are arranged in a square. I want to put a larger, mostly transparent picture box over the top. But when I do it covers the other picture boxes and just draws the background of the form.
Is there a way to get it to have all the other picture boxes show where it is transparent?
Upvotes: 2
Views: 907
Reputation: 110
Here's a tip to get the desired result:
So you will see every copy of your big image covering each picture box as if they were a single image.
Upvotes: 0
Reputation: 12811
Transparency in WinForms isn't great. Some controls have transparency support, others don't. Some controls can be subclassed to enable this (by calling Control.SetStyle()
with the SupportsTransparency
flag). I believe this can be done with PictureBox
.
However, transparency in all WinForms controls works by having the transparent control call its parent control to draw the background before the child control draws. This means that you cannot have two sibling controls and expect transparency on one to show through to the other. Sorry!
All that said, it would be possible to code your own workaround to support this. It would involve subclassing PictureBox
and clever coding in the OnPaint
override to locate sibling controls and manually trigger painting of them into in-memory bitmaps. Lots of gotchas with this approach.
Try WPF!
Upvotes: 3