views:

1556

answers:

1

I have an application that changes the font of every control to SegoeUI when it is run in Vista. It works fine, except for headings of tabpages (the buttons to click when switching from one tab to another).

Tab page headings do not grow vertically to accommodate a larger font size, they always remain the same height.

Is there a property that will allow the TabControl to handle this? (I have tried AutoSizeMode, but it only deals with a tab's width)

If not, what is the best way programmatically to resize the tabpage headings based on the font size?

+2  A: 

There is an ItemSize property on the tab control that you can set to change the size of the tabs themselves. Also, to help you out with getting the size of the text, there's a MeasureString() method on the Graphics object that will give you back a SizeF struct with the size of the given text. That can help you determine if you need to change the ItemSize property. Some rough code:

            Graphics g = this.tabControl1.TabPages[0].CreateGraphics();
            SizeF s = g.MeasureString(this.tabControl1.TabPages[0].Text, this.tabControl1.TabPages[0].Font);
BFree