Setting tabstrip to fit multi column listbox

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,950
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
My Form uses tabstrip above a multi column listbox.
The width of each tab is (I think) determined by the caption size.
My goal is to set the tabs to the same widths as the list columns, irrespective of the captions.
If I'm correct the captions would need padding. The Font is Tahoma Bold 9

Does anyone have any suggestions how best to do this?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Something like this maybe? It might take a bit of trial and error with the space padding and widths as there doesn't seem to be a lot of control over the tab widths in a tabstrip other than through the caption, but someone else may know of a way.

VBA Code:
Private Sub UserForm_Initialize()
    With Me.ListBox1
        .Width = 290
        .ColumnHeads = True
        .ColumnCount = 2
        .ColumnWidths = "3 cm;7cm"
    End With
    With Me.TabStrip1
        .Width = 290
        .Tabs(0).Caption = Space(10) & "Longer caption"
        .Tabs(1).Caption = Space(77) & "x"
    End With
End Sub

1722495695686.png
 
Upvote 0
Thanks for the ideas. I think it was a big ask, as you've confirmed, you can only set the width fore the whole tabstrip.The tab captions vary too. My only solution may be to adjust manually and hard code the widths for each. Knowing the column widths doesn't help.
I'm trying this out out but open to any other suggestions.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top