I created a TransparentTableLayoutPanel:
class TransTablePanel : TableLayoutPanel
{
public TransTablePanel()
{
}
protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
return createParams;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
// Do not paint background.
}
}
And a transparent PictureBox (I tried just using BackColor = Transparent and it didn't work)
class TransPicBox : PictureBox
{
public TransPicBox()
{
}
protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
return createParams;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
// Do not paint background.
}
}
Here is the result:
First cell is the PictureBox with this paint event:
private void picBoxCompass_Paint(object sender, PaintEventArgs e)
{
Bitmap b = Properties.Resources.Compass_Rose;
float rot = PitControl.GetPitbullRotation();
e.Graphics.DrawImage(rotateImage(b, rot), 0, 0, picBoxCompass.Width, picBoxCompass.Height);
e.Graphics.DrawLine(LinePen, picBoxCompass.Width / 2, 0, picBoxCompass.Width / 2, picBoxCompass.Height / 2);
e.Graphics.FillPie(Brushes.Green, picBoxCompass.Width / 2 - 10, picBoxCompass.Height / 2 - 10, 20, 20, 0, 360);
}
And you can see that is not Transparent (Black Background) and second cell is transparent (you can see my form's background image).
How can i make the PictureBox Transparent ?