This code example requires that you have a Form with at least one child control; however, a child container control, like a Panel or GroupBox , with its own child control s would better demonstrate the recursion.
ControlStyles is set to true. The BackColor property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a Button will have the same BackColor as its parent Form by default. For more information about ambient properties, see the AmbientProperties class or the Control class overview. When overriding the BackColor property in a derived class, use the base class's BackColor property to extend the base implementation.
DrawString TabControl1. TabPages e. Text, Me. Font, Brushes. Black, e. Y End Sub. IsaacTheIceMan Newcomer. Joined Oct 27, NET I haven't found a way to actually change the back ground color but I've done the next best thing. This code only works with a single line tab control. Consider the following code FillRectangle new SolidBrush Color. Lavender , this. GetTabRect this. TabCount Top, this. Right, e. Bottom - e. Top ; e. Gray , this. Right-1, this. Right-1, e.
Bottom ; e. White , this. Left, this. Right, this. LightSteelBlue , e. Left - 1, e. Font, FontStyle. LinearGradientBrush e.
Bounds, SystemColors. Control, SystemColors. Control, System. Bounds, Color. LightSkyBlue , Color. LightGreen, System. FillRectangle bshBack, e. X, recTab. Width, recTab. Height - 4 ; e. Aravind Aravind 2 2 gold badges 10 10 silver badges 15 15 bronze badges. I don't think the standard. NET TabControl allows you to set this "free space" to the right of the tabs to a specific background color - it's transparent and just shows the form's background color.
There are more good reasons not to do this than there are to do it. However, doing this no longer sets the background empty space to transparent and instead it sets it to system. Add a comment. Active Oldest Votes. Bounds ; break; case 1: e. Blue , e. Bounds; paddedBounds. Inflate -2,-2 ; e. DrawString tabControl1. Text, this. Font, SystemBrushes. Ash Ash Works great, but how would you change the color of the area behind the tabs?
After all, the question was for the tabs headers, not general user draw — John Stock. Marc Gravell Marc Gravell k gold badges silver badges bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
0コメント