TabControl background color

I would like to set the background color of a 
tab control (more precisely the background color of the area next to the tabs). 

I guess I have to create a custom class inherited from TabControl where I override the OnPaint method...  Could anyone provide a code sample please

Thanks a lot!


Answer this question

TabControl background color

  • aroma01

    In Visual Studio do a search for "Targeting a .NET Framework Version", its a one pager with instructions.

    Basically set you configuration file to:

    < xml version ="1.0" >
    <configuration>
    <startup>
       <supportedRuntime version="v1.1.4322" /> 
    </startup>
    </configuration>


  • Sachin.Khairnar

    I don't have experience with Magic Library yet, sorry. Like I mentioned, I found it while looking for a solution for you.

    I'm still relatively new to VB.NET (came from VB6). What I'm doing now is re-creating my library of controls and types. As DOTNET encourages, I'm trying to doing everything in the appropriate OOP method so I can turn on the afterburners and engage the RAD development. :)

    I just finished a bunch of my own controls and am still building my library. You can see my current list here: <A href="http://www.apesoftware.com/code/desktop/">Current Ape Library</A>

    If you find anything you want in my library, let me know and I'll post or send it to you. I'll keep the TabControl BackColor property in mind and try to add a control to my library that solves the problem because I certainly don't like it the way it is now.


  • pet9834792873928347

    PontiMax,
    I've been using MagicLibrary for around a year and all i could say is, it's a brilliat piece of code, i took the time to study the codes and modify a thing or two. 
    If you don't need other controls it will be fine, you don't have to, once you put this library onto your toolbox, you just drag the TabControl, use it as it is a standard tab control

  • lauch

    vbasics, logicdev, 
    thanks for your comments!

    I stumbled across the Magic library a few days ago. But although it looked as if it provided an answer to my problem I hoped to find a simpler solution - with less overhead. After all, I don't need docking windows, tabbed groups etc., I just want to get rid of that bothersome gray area... :-(

    vbasics, do you already have some experience with the library

    logicdev, I would like to give your solution a try. But unfortunately I don't have a clue how to target version 1.1 of the .NET framework (I have installed both of them, 1.0 and 1.1)...

    Thanks again!

  • denis1900

    In the meantime I've installed the Magic Library, customized my VS.NET toolbox, and dragged a TabControl onto my form. 

    But if I set its BackColor property to SystemColors.ControlDark, the background color of the area I mentioned in my previous posts doesn't turn to ControlDark but to some brighter color. Instead of that the background color of the tabs turns to ControlDark... !  (The Appearance property is set to "MultiForm"!)

    What I would like to have is a dark gray panel which contains a gray tab control. The tab control in turn contains some white tab pages. And of course - the strip to the right of the tab "handles" should be the same background color as the panel (dark gray)...

    How can I accomplish this

    Thanks!!

  • Stephen Weatherford MS

    Mark,
    with "area next to the tabs" I mean the gray strip to the right of the selectable tabs.

    I would like to embed the tab control into a panel. The strip I'm talking about should adopt the background color of that panel...

    Many thanks for your help!!


  • xavito

    The page "http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemwindowsformsapplicationclassenablevisualstylestopic.asp" states that visual styles are only supported on Windows XP and the Windows Server 2003 family.

    Since many of our customers use 2k boxes I probably have to go for the Magic library - or wait for the release of your TabControl, vbasics... ;-)

    Thanks for your feedback!

  • Julie Brazier

    I see what you're talking about now. It's frustrating and it's hard to correct. There's 3 primary ways to fix this. One is to use Graphics or GDI to color in the areas you want changed. Two is to completely re-create the control. (I've done this for the exact same reason for the DateTimePicker. Mine now can control the backcolor and has a few other cool events/features.) THREE and the most likely choice is to simply use someone else's that's already solved the problem. That's what I'm going to do for now.

    You can find a new TabControl from DOTNETMAGIC that will do what you want and it's FREE. All you have to do is give them credit for using it and not try to resale it for $$.

    http://www.dotnetmagic.com/index.html

    I found this while looking for a solution to your problem. I think I'll give them a try as well. Free is free after all and their components looks pretty good. I'll know better later.

    Have fun!

  • coozdrm

    The gray area is very annoying, and if Alignment is set to Left or Right its really bad.

    Here is something I discovered in .NET Framework version 1.1 that makes that gray area transparent (same as the form background):  You use Windows XP styling by enabling visual styles (new to ver 1.1).

    (1) Your form must be loaded from a Main() as follows:

    static void Main() 
    {
    Application.EnableVisualStyles();
    Application.Run(new myForm());
    }
    You have to EnableVisualStyles BEFORE the form is created, that’s why you have to use a Main method to start your app.  Remember to change the start-up configuration.

    (2) Several of the controls, like Button, support a property called FlatStyle, set them to System if you want them to have the XP Style too.  This step is not necessary to fix your TabControl gray area problem.  In fact, TabControl doesn't have a FlatStyle property.

    There is one problem with all this.  There appears to be a bug (or design flaw) if you are using images on you Tabs.  The EnableVisualStyles() wipes out your images as if you never used them.  But if you are not using any images on the tabs it works fine.  Also, I have no idea if EnableVisualStyles requires Windows XP to have an effect.  

  • rfolk73

    Sounds fun so I'll give it a try. What "area next to the tabs." are you talking about
  • TabControl background color