Tabstrip Tabs Width

D

Darren Hill

I'm using a Tabstrip control.
I would like to position a textbox just to the right of the rightmost
visible tab.
Since the number and width of those tabs will vary, I need a way to
figure out the current width of all visible tabs.

Is this possible?

Thanks.

Darren
 
B

Bernie Deitrick

Darren,

You could force the width to be a standard by using the TabFixedWidth property. Or just put the
textbox on the userform in a consistent location. Or use the Contril Tip Text of the tab to contain
your text.

HTH,
Bernie
MS Excel MVP
 
P

Peter T

Try adding all the tab captions to a hidden textbox, font same as the
tabstrip and its Autosize property true. Will also need to add a bit of
padding for each tab and deduct a bit of padding in the textbox. If you play
around should get it pretty close.
newLeft = tabstrip1.left + textbox1.width

Regards,
Peter T
 
D

Darren Hill

I've Hi, Bernie.
I've tried fiddling around with the TabFixedWidth property but I must be
doing something wrong - as all but one of my tabs vanish when I use it.
Can you give a simple example of using the tabfixedwidth ?

I can't use the Control Tip, because the text box allows data entry.

Thanks for the suggestions, though.

Darren
 
D

Darren Hill

Oh, that looks like something I can do.
Thanks for the suggestion, Peter. I'll start experimenting.

Darren
 
B

Bernie Deitrick

Darren,

Create a new userform, insert a tab strip, and then use the code below in the userform's module.
Each click on the userform will increase the tabwidth, and a double-click will reset it. See what
happens....

HTH,
Bernie
MS Excel MVP


Private Sub UserForm_Click()
UserForm1.TabStrip1.TabFixedWidth = UserForm1.TabStrip1.TabFixedWidth + 20
End Sub

Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
UserForm1.TabStrip1.TabFixedWidth = 20
End Sub

Private Sub UserForm_Initialize()
Dim i As Integer
i = 1
With Me
.Width = 500
.Height = 500
With .TabStrip1
While .Tabs.Count < 5
.Tabs.Add "New tab" & i
i = i + 1
Wend
.MultiRow = True
.Width = 400
.Height = 400
.TabFixedWidth = 20
.Left = 50
.Top = 50
End With
End With
End Sub
 
D

Darren Hill

Thanks for the code.
I was a bit confused at first, since the double click seems to be a bit
sensitive on my set up. I thought I was just single clicking, which had
me examining you code to find what was causing the unpredictable return
to starting conditions. Oops :)
But I understand now. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top