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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tab control labels 2

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
Is there a way to increase the width of a tab control label? I don't really want 2 lines because the second line would be so short that it would look odd.
I've tried to change the width but it keeps reverting back to the original size.

Thanks
lhuffst
 
Won't the width of the label be dependent on the text in the label? That is what I have always found. FYI, tab controls do not have a lot of flexibility in the customization of labels. I use them here and there, and I don't spend a lot of time with the labels, simply because it's a lot of investment to get them to do anything fancy, and not much pay-off for it. This may or may not help, but I found this post on tab controls that might have some helpful tips for you. I didn't see anything specifically on this, but hopefully you can get something of use from it.


misscrf

It is never too late to become what you could have been ~ George Eliot
 
misscrf said:
Won't the width of the label be dependent on the text in the label? That is what I have always found.
I've always thought the same thing :)

If the post above doesn't help I was able to find a Microsoft (About Tab Controls Page) that gives details about tab control styles that could maybe help you specify width.
"A tab control automatically sizes each tab to fit its icon, if any, and its label. To give all tabs the same width, you can specify the TCS_FIXEDWIDTH style. The control sizes all the tabs to fit the widest label, or you can assign a specific width and height by using the TCM_SETITEMSIZE message."

Amanda Long
Web specialist
 
nice find, Amanda!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Not sure how Amanda's post helps, since that is a windows control and not an Access control
In access you have two options: use the native access control or you can go to ActiveX controls and add an MSFORMS tabstrip.
In both you have the option to set the fixed width property. So do not really understand the original issue. With the MSFORMS control you have some flexibility that you do not have with the native control.
One thing you can also do to get a lot of flexibility is to go to style and select "none" this will give you a tab control without any tabs. Make your own tabs out of labels. You can have different colors, sizes, fonts, etc. Then some code like this to control it to make it look depressed.
Code:
Public Function changeTab(intTab As Integer)
    Me.tbCtrl1.Value = intTab - 1
    depressLabel (intTab)
End Function

Public Sub depressLabel(intLabel As Integer)
  Dim lblCount As Integer
  Dim i As Integer
  lblCount = Me.tbCtrl1.Pages.Count
  For i = 1 To lblCount
    With Me.Controls("lbl" & i)
      'Flat and unBold
     ' .SpecialEffect = 2
      .FontBold = False
      .FontUnderline = False
      .FontItalic = 0
      .BorderStyle = 0
    End With
  Next i
  With Me.Controls("lbl" & intLabel)
    'Sunken Bold
    '.SpecialEffect = 1
    .FontBold = True
    .FontUnderline = True
    .FontItalic = True
  End With

End Sub
in the onclick event of each label put "=changeTab(1)" where 1 is the label number.
 
From the post, I figured out I was clicking on the wrong part of the tabbed form. You have to go to the far right and click on that "main tab form". Then I set the width of the labels there -- worked like a charm. The far right tab doesn't have any labels on it and you can't place anything on it since it is the control itself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top