Page Break *if necessary*

edited 12:08PM in FastReport .NET
Dear Ladies and Gentlemen,

How do I make a page break *if it is necessary*?

I want to get the whole table together. If there is enough space on the current page, the entire databand should be displayed on this page.
If there is not enough space on the current page, a page break should be inserted.

Best Regards
Mira

Comments

  • edited September 2018
    it????????¬???????s just a thought :
    1. set report to double-pass
    2. at first-pass : calculate the height of detail data
    3. at final-pass : page break is done by adjusting header's height
    4. look at my sample (groups.frx & data.xml), i couldnt understand the way fastreport think, why do i need to adjust 18.9F (data1.height) in code :
        private void PageFooter1_BeforePrint(object sender, EventArgs e)
        {
          if (Engine.FinalPass)
            position = 18.9F;
        }
    
    perhaps because record.movenext in data1

    5. avoid 'cangrow' property, more headache [img]style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> 6. an alternative: page break is done by engine.startnewpage();[/img]
        private void GroupHeader1_AfterPrint(object sender, EventArgs e)
        {
          if (Engine.FirstPass)
          {
            height = 0;
          }
          else
          { 
            if (position + groupHeight + list[counter] > contentHeight)
              Engine.StartNewPage();
            else                     
              position += groupHeight;
            counter += 1;
          }
        }
    
  • edited 12:08PM
    Thank you for your suggestion!

    We haven't been able to get your solution to work in our project but we have found another solution that seems to be working:
                            CurrentReport.FindObject<DataHeaderBand>("DataUsedHeatTransferCoefficients_Header").BeforePrint += (sender, e) =>
                            {
                                if (!CurrentReport.Engine.FirstPass)
                                {
                                    if (CurrentReport.Engine.FreeSpace < contentHeight + CurrentReport.FindObject<BandBase>("DataUsedHeatTransferCoefficients_Header").Height)
                                        CurrentReport.Engine.StartNewPage();
                                }
                            };
                            CurrentReport.FindObject<DataBand>("DataUsedHeatTransferCoefficients").AfterPrint += (sender, e) =>
                            {
                                if (CurrentReport.Engine.FirstPass)
                                    contentHeight += CurrentReport.FindObject<BandBase>("DataUsedHeatTransferCoefficients").Height;
                            };
    

    The snag is that this has to be repeated for each and every table.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.