views:

3183

answers:

4

How can I change the background color of a Tab Control. I changed the forms color, but the tabs stay the same.

Thanks.

+1  A: 

Check the Back Style of the Tab Control. If it's Normal. you'll get a gray background (with normal Windows settings). If it's Transparent then it will inherit the background colour of the form.

If you want it to be an entirely different colour, you might have to add a rectangle to the form (make the background non-transparent), maximise it within the tab and then set the colour of the rectangle.

As for the tabs them selves, I don't see a way of setting their colour independently.

CodeSlave
+3  A: 

As far as I know, in Access 2000/2002/2003 it's impossible to change neither background, not foreground colors of the tabs.

So, if you want to change the appearance of entire tab control, I think you are out of luck.

However, if your real goal is to implement some sort of color-coding of a tab control's pages, here is what I did when I had this problem:

  • I placed a colored rectangle on each page of the tab control to provide different background colors for different pages.

  • As for tabs themselves. Fortunately they can contain images, so I created trivial image files, each of which was a small colored bullet (square, rectangle, circle - whatever looks nicer to you) and placed them on tabs, next to text labels.

Thus, the entire control still remained grey (or whatever is the current "button color" in the Windows's current theme), but each tab and each page got associated with whatever colors I needed them to have.

Yarik
+1  A: 

You can mock this up with a little code. Set the the Style property to None for the tab control and the use any other control that has a click event to create your own colourful tabs (you can even have images). Your code can either change tabs, or change the contents of a subform.

Change tab:

 Me.NameOfTabControlPage.SetFocus

Change subform control contents:

 Me.NameOfSubformControl.SourceObject = "NameOfSuitableForm"
Remou
A: 

CodeSlave made the very good suggestion:

If you want it to be an entirely different colour, you might have to add a rectangle to the form (make the background non-transparent), maximise it within the tab and then set the colour of the rectangle.

If you want to have a background that is larger in relation to the tab dimensions than the tab allows (there is a hard border that can't be exceeded), there is another solution (though it's somewhat more complicated -- which is what usually happens when you are tweaking appearance to not work the way your default environment is designed to work).

Set the tab control to transparent. Behind the tab, place a non-transparent box. Then in the OnChange event of the tab, change the background color of the box behind the tab.

Kinda messy, yes, but it allows you to have a background that is as large as the whole tab (or larger still, in the event that you might want items off the tab inside the same color field).

David-W-Fenton