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
Not quite working for me. Although I converted this to VB.NET. And I am extending the UltraTab class.
Cheers
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; }
Hello Andez,
At that moment we have not implement such kind of automatic functionality. Maybe you could try to set at design or run time desired width, using FixedWidth property.
Please let me know if you have any further questions.
Regards
Hi Georgi,
FixedWidth doen't seem to work too well. Unless it is possible to calculate the width based on the string length and format. The problem I have is only when the font is bold. FixedWidth is set to 0 in this instance.
I will have another play with it later.
One possible way to change the Tab`s width, could be if you are using FixedWidth property. Please take a look at the attached video file for more details and let me know if you have any questions.