Hi,
Is there some way to change the width of a header when the font is bold?
If you enter a long string for the text, i.e. "tab1234567890" it displays ok - the entire string.
As soon as you change the font to bold, it shows "tab1234567..." you get the elipsis (...) at the end.
Change it to "tab123456789012345678901234567890" without bold, it displays ok.
The effect is the same whether doing it in the designer or through code.
Is this a bug or am I doing something wrong?
Thanks,
Andez
I asked a similar question a few weeks back. I ended up using the following function, which I called after making changes to the tab title and appearance. Seems to mostly work, even when adding characters or adding/removing bold stuff. I'm sure there is some optimizations (handling the Bold being Default instead of True).
private void ResizeTabWidth(UltraTab tab) { // This assumes that tab.Appearance is set up before this is called. // Figure out which font we're using. FontStyle fontStyle = tab.Appearance.FontData.Bold == DefaultableBoolean.True ? FontStyle.Bold : FontStyle.Regular; float fontSize = 8; Font font = new Font("Arial", fontSize, fontStyle); string text = tab.Text; bool canClose = tab.AllowClosing == DefaultableBoolean.True; // Recalculate the new width of the tabs. If there is a close button (canClose is true), then we need to // add space for that. Graphics graphics = CreateGraphics(); graphics.PageUnit = GraphicsUnit.Pixel; SizeF textSize = graphics.MeasureString(text, font); int decorationWidth = 12; if (canClose) { decorationWidth += 15; } // Set the fixed width of the tab. tab.FixedWidth = (int)Math.Ceiling(textSize.Width) + decorationWidth; }
Not quite working for me. Although I converted this to VB.NET. And I am extending the UltraTab class.
Cheers