GetPreferredWidth issue with child views

Posted by: j2associates on 8 September 2017, 1:10 pm EST

  • Posted 8 September 2017, 1:10 pm EST


    If I call the GetPreferredWidth method on expanded child rows, it returns the default width based on  the column type. In the main sheet, I can overcome this by applying a renderer to the ColumnHeaders and changing the WrapText? property. But there is no ColumnHeader property for a SpreadView so how do I get narrow columns? In the attached jpeg showing the differences, note the tight column widths for the parent row as opposed to the wide column widths in the childe rows. Thanks in advance for any ideas and/or suggestions!

  • Replied 8 September 2017, 1:10 pm EST

    j2 -

    Try setting DataAutoSizeColumns to false for the child view...

    Private Sub FpSpread1_ChildViewCreated(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.ChildViewCreatedEventArgs) Handles FpSpread1.ChildViewCreated
    e.SheetView.DataAutoSizeColumns = False
    e.SheetView.Columns(0).Width = e.SheetView.Columns(0).GetPreferredWidth

    End Sub
  • Replied 8 September 2017, 1:10 pm EST

    Hello BobM,

    The ChildViewCreated event never fires in my code although the ChildWorkbookCreated event fires. Putting your code in the latter event didn't change anything but you pointed me in the right direction. In my Expand event code I have the following which works:

    <FONT size=2>

    e.View.GetSheetView.GetChildView(e.Row, 0)<FONT size=2>.DataAutoSizeColumns = </FONT><FONT color=#0000ff size=2>False

Need extra support?

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

Learn More

Forum Channels