transparent panel

  • Thread starter Thread starter Marco Martin
  • Start date Start date
M

Marco Martin

Hi,

I have a picturebox with a bitmap inside. I need to add a panel to the
picturebox, but I have to see behind. Meaning, the panel has to be
transparent but not invisible. This panel will hold other images that I
will or wont display through code.

I'm saying panel, but it really doesn't matter. It could be any container
control that has height/width and location properties.

Any ideas would be greatly appreciated.

regards,

Marco
 
Found a way. By overriding the onPaintBackground method:

private class TransparentPanel : Panel

{

public TransparentPanel()

{

}

//This method makes sure that the background is what is directly behind the
control

//and not what is behind the form...

override protected CreateParams CreateParams

{

get

{

CreateParams cp = base.CreateParams;

cp.ExStyle |= 0x20;

return cp;

}

}

override protected void OnPaintBackground(PaintEventArgs e)

{

// do nothing

}

}
 
Back
Top