GetPreferredWidth not working for headers in 4.0

Posted by: zenrhapsody on 8 September 2017, 1:24 pm EST

  • Posted 8 September 2017, 1:24 pm EST


    GetPreferredWidth is not checking header width in 4.0.  I have some custom headers that are longer than default column width of 60 pixels.  Text in these cells does not fit in the width returned by GetPreferredWidth.

    I did find a post here about creating a new ColumnHeaderRenderer and setting WordWrap to false as follows:

    <FONT size=2>

    </FONT><FONT color=#008000><FONT face=arial,helvetica,sans-serif size=1>ColumnHeaderRenderer c = new ColumnHeaderRenderer();</FONT>


    <FONT color=#008000><FONT face=arial,helvetica,sans-serif size=1>c.WordWrap=false;</FONT>


    <FONT color=#008000 size=2><FONT face=arial,helvetica,sans-serif size=1>sv.ColumnHeader.DefaultStyle.Renderer=c;</FONT>

    </FONT>I tried this code, and it did fix the with problem.  However, I want the new color styles in Spread 4.0.  The above code reverts the background to battleship grey.

    How can I keep the nice new automatic styles in Spread 4 and fix my column width issue?

  • Replied 8 September 2017, 1:24 pm EST

    Have you tried the following...

    Dim eh As New FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer
    eh.WordWrap = False
    FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle.Renderer = eh

  • Replied 8 September 2017, 1:24 pm EST

    perfect! Thanks!


  • Replied 8 September 2017, 1:24 pm EST

    Hopefully someday the WordWrap default will be False so that GetPreferredWidth acts consistently with what the docs explain.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels