2

Possible Duplicate:
A PictureBox Problem

I have a TabPage which hosts some custom PictureBox controls. What I do here is drawing some IC packages which user can click on theire pins to get some info. User can add multiple of this pictureboxes to the tabpage and move them around in the tabpage.

My problem is that this pictureboxes are transparent, only when they are not over each other. In the image below you see two of this pictureboxes added to tabpage. The tabpage has a blue background, in fact, it doesnt matter what color it has, the pictureboxes will have theire undrawn areas transparent to the tabpage:

enter image description here

But as soon as I move any of thise pictureboxes above another, it will not be transparent anymore:

enter image description here

This is the code that produces raw Image that I will draw on it:

    //Setting up image area
    Image = new Bitmap(requiredImageWidth, requiredImageHeight, PixelFormat.Format32bppArgb);
    Image.MakeTransparent();

The rest are default settings I didnt change anything else. What do you think causing this behaviour?

Community
  • 1
  • 1
Dumbo
  • 13,555
  • 54
  • 184
  • 288
  • It doesn't redraw background on move. Try to call `Image.MakeTransparent();` on picture box move. But calling this might be expensive and my guess picture will flicker. – Renatas M. Aug 27 '12 at 09:05
  • Also [this](http://stackoverflow.com/questions/7874134/transparent-control-on-transparent-control/7876863#7876863) might be interesting – Renatas M. Aug 27 '12 at 09:13

1 Answers1

7

From this article, this is what's causing this behaviour :

Transparent controls in WinForms are transparent relative to their parent, not to other controls. Transparency in WinForms is more akin to camouflage than true transparency. A transparent control doesn’t actually let you see the control behind it through the form. It asks its parent to draw its own background on the "transparent" control. This is why a transparent control shows the form behind it, but covers up any other controls.

There is an accepted answer to your problem here (A PictureBox Problem)

Community
  • 1
  • 1
Nasreddine
  • 36,610
  • 17
  • 75
  • 94