PageHeader - CanGrow works as designed

Posted by: via on 4 August 2017, 3:03 pm EST

  • Posted 4 August 2017, 3:03 pm EST

    My previous title was

    'PageHeader - CanGrow does not work'.


    Section.CanGrow works as designed.

    The section hight expands if any its controls (EXCLUDE CONTROLS BEYOND ITS AREA) grow beyond its area.

    To do not miss any control in the report I need to calculate height of all sections before run and I need to calculate height of section in section_format event (if position of control has been changed).
  • Replied 4 August 2017, 3:03 pm EST


    I'm curious as to why you're trying to calculate the heights of sections and controls before the report has run and again in the Format events. I've noticed that often when someone tries to do this, there is a much simpler approach to the accomplish the same task.

    However, typically the best place to check heights is in the BeforePrint events of your sections. Although by that time you cannot change the heights.

  • Replied 4 August 2017, 3:03 pm EST

    I need to calculate the heights of sections before run when the section.CanGrow

    = True because 'CanGrow' does not show the section controls BEYOND ITS INITIAL AREA.

    Here is the code that I mean:

    Dim rpt As ActiveReport

    Dim sect As Section

    Dim j As Integer

    Dim InitialHeight As Single

    For Each sect In rpt.Sections

    If sect.CanGrow = True

    InitialHeight = 0

    For j = 0 To sect.Count - 1

    If TypeName(sect.Controls(j)) = "Field" Then

    If sect.Controls(j).top + sect.Controls(j).height > InitialHeight Then

    InitialHeight = sect.Controls(j).top + sect.Controls(j).height

    End If

    End If

    Next j

    sect.height = InitialHeight

    End If


    To exlain that I need to calculate the height of section in section format event

    I attached a sample. You can see that second subtotal is missing.
  • Replied 4 August 2017, 3:03 pm EST

    You should be able to sum the height of the TextBoxes added to the Section while building the dynamic report. Then set the height of the Section to that, plus a small margin if necessary. When the report runs everything should be able to grow as needed.

    However, if you would still like to calculate the section heights in your own code, you may be able to use the MeasureParagraphHeight() and MeasureText() methods to help in your estimation. See the following links for more information.

Need extra support?

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

Learn More

Forum Channels