none
TabControl - BackColor Changing

    Question

  • VS2010 VB.Net Windows Forms

    I have 100+ forms and it seems the BackColor of the TabControls are being changed w/o any input from me. A few months ago 100% of the tabs had a Gray 'System - Control' background. Today some of them have a White (transparent?) back ground. I have NOT been changing the setting nor any other properties of the tabs. I have been making code changes but very few if any GUI changes.

    This is very bad behaviour on the part of VS.

    Any idea how I can stop this behaviour?

    Any way I can recover other than visting 100+ forms with 4-10 tabs each and explictly setting the BackColor to System - Control?

    What does Transparent mean any way - I don't have any controls under the TabControls that have White as their BackColor.

    Thursday, January 27, 2011 4:24 PM

Answers

  • I see Me.<tabName>.UseVisualStyleBackColor = True in the designer for all the tabs.  I don't remember adding this property intentionally but....

    Looking back to the VS2003 project that this one was derived from the property is set there as well.

    I ran an .EXE created back in 2008 on VS2003 and the tab backcolor is  displayed white. I know for certain that back in 2008 (and up until the last few months) the tab backcolor was gray (control.)

    This problem appears on XP, Vista, and Win7 desktops.

    So evidently .Net (or some core component) has changed how Visual Styles are applied to the tabs sometime in the last few months.

    • Marked as answer by Bob Heitzman Wednesday, February 09, 2011 7:17 PM
    Wednesday, February 09, 2011 7:17 PM

All replies

  • I've never seen such behaviour. The closest is when control uses the default color that inherits from the form. So when you change the back color of the form, the control changes also, aside from that, something must've happened, I can't reproduce your issue.

    In fact, the default color for the TabPage is transparent, so maybe it was reset to the default value. So you don't need to replace the color of all TabControls, you can replace the text of FormXXXX.Designer.vb to include changing to the color you want. You can use text search and replace mechanisms to replace the color if your lucky they are beeing set (which I beleive they aren't). You could also check the repository for the older versions of the Designer files (for 100+ forms, if you don't have this, well, something is very wrong) and recover them since you did not change UI elements.

     

    Transparent means transparent, but in many cases when the color is not supported, some controls show a messagebox, others simply treat it as white.

     

    Regards,

    Fábio


    "To alcohol! The cause of and solution to all of life's problems." - Homer Simpson
    Thursday, January 27, 2011 5:27 PM
  • I haven't seen it either - that's why I made the post.
    Friday, January 28, 2011 4:32 PM
  • I doubt you'll find anyone with the same issue, so I think the best you can do is use the Designer.vb files to make it back, it shouldn't take long, depending on how each file is. If there is a setting for the tab page to the color, then it will be easy to just replace (Find Replace), if you have to add a new line setting the color, then it will be a little trickier, because probably you have custom names for each tabPage, if not it will be a little easier (tabPage1.Backcolor, tabPage2.BackColor, for every file).

     

    Regards,

    Fábio


    "To alcohol! The cause of and solution to all of life's problems." - Homer Simpson
    Friday, January 28, 2011 5:07 PM
  • If you've not changed any settings then it should not be changing.

    The TabPage has a UseVisualStyleBackColor property which defaults to false, but which the IDE sets to true when the page is created. When this property is set to true and the TabControls Appearance property is set to Normal, the TabPages BackColor property will default to Transparent. If you don't want this behaviour then you will have to specifically set each tabPages UseVisualStyleBackColor property to false. You can do this fairly easily by using "Replace in Files" to change every instance of "UseVisualStyleBackColor = true" to "UseVisualStyleBackColor = false".

    When Visual Styles are in use, and the TabPage backcolor is set to transparent, the tabpage will be painted using the texture as defined by the active Visual Style. If not defined in the visual style then the TabPage will be painted in the TabControls BackColor (which is always SystemColors.Control).

    Transparent is not really transparent, if you set a controls background color to Transparent then it will simply paint the relevant portion of its Parent to its background (remove all pages from a tabcontrol and see what color it is).


    Mick Doherty
    http://dotnetrix.co.uk
    http://glassui.codeplex.com
    Saturday, January 29, 2011 1:51 PM
  • If a add a new Windows Form and add a tab control the tabs are white (BackColor Transparent.) I don't remember this being so in the past (maybe pre VS2010), I thought these always appeared as Gray (probably Control.)

    As you noted if you remove all the tabs annd the TabControl client area is white and there does not appear to be a property to control the color. I would hope that the TabControl would inherit the BackColor of it's parent but that is evidently not true.

    I've been noticing on some random MS dialogs that the backcolor is now white. Again I don't remember this being the case with the vast majority having "control" which I would guess is inherited from the desktop theme.

    I'm running on Vista.

     

    Friday, February 04, 2011 6:35 PM
  • This didn't happen in VS2003, but I'm pretty sure that it's been the case since the VisualStyles classes were added in VS2005 (FW 2.0). TabControl was updated to use those classes at the same time.

    Have you recently changed your Windows Theme? (not all themes use a texture)


    Mick Doherty
    http://dotnetrix.co.uk
    http://glassui.codeplex.com
    Sunday, February 06, 2011 8:01 PM
  • I see Me.<tabName>.UseVisualStyleBackColor = True in the designer for all the tabs.  I don't remember adding this property intentionally but....

    Looking back to the VS2003 project that this one was derived from the property is set there as well.

    I ran an .EXE created back in 2008 on VS2003 and the tab backcolor is  displayed white. I know for certain that back in 2008 (and up until the last few months) the tab backcolor was gray (control.)

    This problem appears on XP, Vista, and Win7 desktops.

    So evidently .Net (or some core component) has changed how Visual Styles are applied to the tabs sometime in the last few months.

    • Marked as answer by Bob Heitzman Wednesday, February 09, 2011 7:17 PM
    Wednesday, February 09, 2011 7:17 PM
  • VS2003 used framework 1.1.

    Framework 2.0 didn't appear until VS2005.

    TabPage.UseVisualStylesBackColor property appeared in Framework 2.0 along with the VisualStyles classes.

    A VS2003 project would have had System.Control color tabpages (unless set otherwise) because the tabcontrol did not use the tabpage texture. The VS2003 project would not have set the UseVisualStylesBackColor property as it did not exist, so if this line was written the project would not have compiled. I even wrote a custom TabControl class to overcome the issue in VS2003 (http://dotnetrix.co.uk/tabcontrol.htm#tip10). This behaviour was added in VS2005 after many requests via the MS Connect feedback pages (Visual Studio feddback pages at the time).

    As I explained earlier, Me.<tabName>.UseVisualStyleBackColor = True is set by the IDE on creation of a tabpage even though true is not the default value.

    Are you seeing this property set in a VS2003 project or are you seeing it in a converted VS2003 project? I suspect the latter.

    The tabs have applied Visual Styles in exactly the same way since VS2005, but it is possible that a converted VS2003 project would not have had this property set and may only have updated it once you opened the forms designer.


    Mick Doherty
    http://dotnetrix.co.uk
    http://glassui.codeplex.com
    Wednesday, February 09, 2011 10:41 PM
  • I mis-spoke - VS2005 was our previous platform.

    And it does appear that the UseVisualStyleBackColor was set to true when the form was created back in 2005 days.

    Regardless - the backcolor of the tabs has changed on a variety of OS's w/o any change in our code.

    Thursday, February 10, 2011 9:19 PM
  • In that case, UseVisualStylesBackColor will have been set to true unless you specified otherwise.

    The difference in the tabpages appearance can be put down to the active Visual Style itself. IIRC In XP only the Silver theme has a texture bitmap defined, the blue and olive themes will use the default Control Color. I never used Vista, so I don't know about that, but Windows 7 may or may not use a texture dependant upon whether or not DWM is running.

    I suspect your issue is down to the OS and not down to Visual Studio doing things differently, although I can't say I've ever noticed your symptoms and I spend quite lot of time playing with TabControl.


    Mick Doherty
    http://dotnetrix.co.uk
    http://glassui.codeplex.com
    Friday, February 11, 2011 4:33 PM
  • I doubt you'll find anyone with the same issue, so I think the best you can do is use the Designer.vb files to make it back, it shouldn't take long, depending on how each file is. If there is a setting for the tab page to the color, then it will be easy to just replace (Find Replace), if you have to add a new line setting the color, then it will be a little trickier, because probably you have custom names for each tabPage, if not it will be a little easier (tabPage1.Backcolor, tabPage2.BackColor, for every file).

     

    Regards,

    Fábio


    "To alcohol! The cause of and solution to all of life's problems." - Homer Simpson

    I'm having this issue too.  I was working on a design in VS2005 adding a tab to a form.  When I got done, I noticed that just about every tab had set Me.{TAB_NAME}.UseVisualStyleBackColor = True.  I'm not sure if I accidentally changed it in one place and everything changed or what happened.  I figured out the problem and started going through the tabs to set them back to False and that was working until I looked again and they were all back to True.  I'm now starting to wonder if there is some default setting that once changed is applying itself to everything.

    I think I know what I was trying to do when this changed. I was trying to change the color of a DateTimePicker (before I found out that you have to jump through hoops to do that). I'm guessing that I probably changed UseVisualStyleBackColor, thinking that maybe "that" was the key to changing the DateTimePicker color. Now I'm not sure how to undo this change without chucking the whole thing and starting over.  Maybe I'll just set the BackColor for every tab. (ugg!)

    • Edited by Alan Edwards KAE Tuesday, March 15, 2011 5:20 PM added the last paragraph
    Tuesday, March 15, 2011 5:13 PM
  • Hi Alan, perhaps something changed. Did you upgrade windows? Is the project managed only by you? Is it possible that you have enabled themes on windows?

    Please check the project Properties, Application tab, "Your project" framework properties for the following setting:

    - Enable XP Visual Styles.

     

    Try playing with that setting and check if you get the same behaviour of getting the UseVisualStyleBackColor reverting to True.

     

    Regards,

    Fábio

     


    "To alcohol! The cause of and solution to all of life's problems." - Homer Simpson
    Thursday, March 17, 2011 11:58 AM
  • Hi Fábio,

    I looked at the Project Properties/Application tab and I do have "Enable XP Visual Styles" checked.  I'm not sure what "Enable XP Visual Styles" does for sure. I inherited the code from the person that was here before, so I'm the only one working on the project which means that if something happened I'm the one that did it. (smile)

    Our machines are managed/administered by another group in our company using Domain Controllers and Active Directory. They've got our machines pretty well locked down with strict group policies. XP updates are added automatically.  Windows XP updates have been added, but no "upgrades" have happened for Windows XP (we're still on Windows XP Professional 2002 SP3). I'm using Visual Studio 2005. I don't think I've enabled themes on Windows (Is that the "Themes" tab on the display properties dialog box?)

    It seems like the default for the designer is to not have the UseVisualStyleBackColor property set, because if the line is deleted then the default appears to be False.  The only reason I even noticed was that the background color of the affected views had a white background instead of the default of "Gainsboro". I've been using git for source code control and when I looked at the differences in the designer files that's when I saw a bunch of lines that added the 'UseVisualStyleBackColor  = True' property.

    Thanks for the suggestions, I'll take a look and try some different settings.

    Thursday, March 17, 2011 3:42 PM
  • Hi Alan, Enable XP Visual Styles tells the application to draw it's windows and controls using windows themes introduced in Windows XP. That means that instead of drawing the solid title bar, it will draw the themed title bar (like windows xp Blue/Silve/Olive themes) and the controls will inherit that behaviour by default. The themed tab control does not allow color change (there are ways to change that, but it's off topic) so it will always look white.

     

    The reason I asked about OS upgrade is because maybe the development was beeing done in windows version prior to XP where windows themes were not available, therefore, no reason for visual studio try to apply the themes to the controls like the tab control. Perhaps when the project moved to a theme enabled version of windows, visual studio started applying that to the controls as Enable XP Visual Styles was set.

     

    My suggestion is to try getting the previous version from repository and before opening any forms, disable the XP Visual Styles setting and perhaps the problem will go away. I can't be sure as I don't have the environment available to test that.

     

    I hope this helps solving your problem.

    Regards,

    Fábio


    "To alcohol! The cause of and solution to all of life's problems." - Homer Simpson
    Friday, March 18, 2011 7:47 AM
  • <Font Size=48> SIGH!</Font Size=Normal>

    From all I see no one has an answer to my problem.

    Guess it's one by one. My thanks to all.

    I'll call this closed.


    David (Whose retirement hasn't been as exciting as I was lead to believe.)

    • Proposed as answer by dfschrader0 Wednesday, August 29, 2012 8:01 PM
    Wednesday, August 29, 2012 8:01 PM