Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Tab Controls Font Colour

Status
Not open for further replies.

NHogan

MIS
Aug 23, 2001
40
0
0
CA
I have added a Tab Control with 7 tabs. The subforms and everything are working fine but I have one question. Can I change the Font Colour on the tabs? If so, how? I can't find a property for Font or ForeColour under Tab Control

Please Help me out.
 
No you can't change the color of the tabs. However, you can make the background of the tab control transparent (tabs will still be grey).

This is how I handled the problem. I set the BACKSTYLE property of the tab control to Transparent and set the STYLE property to none (tabs don't show up now). Then I simulated the tabs by placing labels above the tab control. I also set the BACKSTYLE property of the labels to Transparent (but you could make them any color you want). On the OnClick event of each label, I called the following function, passing it the name of the label the user selected. Basically what this function does is change the height of the label selected. By default, my first label is taller than the others indicating that it is the current one selected. You would be hard pressed to notice the difference between the labels and the actual tabs.

2 things to note: mstrLabelSelected contains the name of the label that is currently selected. So you need to initialize it in the OnOpen event of the form. I used FormHeader.Height as my anchor point. You could use the tab control itself, so that if you move the controls, you won't have to change your calculations here.

OnClick ... =SelectTab("lblFirstTab")

Option Compare Database
Option Explicit

Dim mstrLabelSelected As String


Public Function SelectTab(strLabelSelected As String)

On Error Resume Next

If (strLabelSelected <> mstrLabelSelected) Then

Me(mstrLabelSelected).Height = 0.2083 * 1440
Me(mstrLabelSelected).Top = (FormHeader.Height - (0.2083 * 1440))

Me(strLabelSelected).Top = (FormHeader.Height - (0.25 * 1440))
Me(strLabelSelected).Height = 0.25 * 1440

If (strLabelSelected = &quot;lblFirstTab&quot;) Then
tabCtl.Value = 0
ElseIf (strLabelSelected = &quot;lblSecondTab&quot;) Then
tabCtl.Value = 1
End If

mstrLabelSelected = strLabelSelected

End If

End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top