How can i make WinForms TabPage header width fit it\'s title? Here is the problem.
You need to measure the fonts.
Try something like this:
Dim tabPage As New TabPage
Dim width As Integer = 0
Dim valueToMeasure As String =
Dim g As Graphics = tabPage.CreateGraphics()
width = CType(g.MeasureString(valueToMeasure, tabPage.Font).Width, Integer)
Probably add a bot extra on for padding (width = width +10)
Edited:
.width = GetTabWidth()
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