You need to measure the fonts.
Try something like this:
Dim tabPage As New TabPage Dim width As Integer = 0 Dim valueToMeasure As String = <Your title Here> Dim g As Graphics = tabPage.CreateGraphics() width = CType(g.MeasureString(valueToMeasure, tabPage.Font).Width, Integer)
Probably add an extra bot to fill (width = width +10)
Edited by:
<tab>.width = GetTabWidth(<Title>) Private Function GetTabWidth (Byval title as String) as Integer Dim widthValue as Integer = 10 'Padding (Optional) Dim tabPage as New tabPage Dim g as Graphics = tabPage.CreateGraphics() widthValue += Ctype(g.measureString(title, tabPage.Font).Width, Integer) Return widthValue End Function
source share