Hi, nildo,
I want to create a MyTabControl based on TabControl. By
rewriting OnPaint() I draw tabarea and tad head, all works but I can not
make background transparent. The background is alway be filled by grey
color. I can only fill it by other color but can not make it
transparent. TabControl can make background transparent itself.
I tried the way as below.
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
But it does not work. It looks like that the background is filled with grey by some code before my OnPaint() is called.
Thanks.
David.
Loading
Zoran HorvatPosted Nov 16, 2010, 7:35 AM
Even if you do something about this, borders will be drawn by the base class and you won't have opportunity to change that (I think).
One work-around for transparency is to find all controls below tab control and then use their DrawToBitmap method to capture their image. Then combine those images to draw background. Note that you should use double-buffered tab control in that case to avoid flickering (inheirt tab control and set its DoubleBuffered property to true in the constructor). This workaround may become simple if you know what lays under the tab control, but general case seems difficult.
That is one lesson in controls programming - do not help inheritors too much, don't try to read their minds. But most of the built-in Windows forms controls act against that guideline.