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:


    ColumnHeaderRenderer c = new ColumnHeaderRenderer();


    c.WordWrap=false;


    sv.ColumnHeader.DefaultStyle.Renderer=c;


    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