I'd like to know if there's some way to render the background of a TabControl transparent (the TabControl, not the TabPages), instead of taking the parent form background color. I've some forms with custom painting where I draw a gradient as the background but this gradient doesn't paint behind the tabcontrols. I tried setting TabControl.Backcolor = Color.Transparent but it tells me it's not supported. I'm using VS2005 and framework 2.0. (set style does not help) Does anyone have good workaround to this issue?
+1
A:
According to this thread on msdn, the tabcontrol does not support changing the backcolor to transparent, however you can supposedly override the drawitem method.
JYelton
2009-09-06 06:18:07
+1
A:
custom tab conrol:
[DllImport("uxtheme", ExactSpelling = true)] public extern static Int32 DrawThemeParentBackground(IntPtr hWnd, IntPtr hdc, ref Rectangle pRect);
protected override void OnPaintBackground(PaintEventArgs e)
{
if (this.BackColor == Color.Transparent)
{
IntPtr hdc = e.Graphics.GetHdc();
Rectangle rec = new Rectangle(e.ClipRectangle.Left,
e.ClipRectangle.Top, e.ClipRectangle.Width, e.ClipRectangle.Height);
DrawThemeParentBackground(this.Handle, hdc, ref rec);
e.Graphics.ReleaseHdc(hdc);
}
else
{
base.OnPaintBackground(e);
}
}
Golan
2009-09-06 07:00:55