Ticket Q364626
Visible to All Users

How to hide the page header if there are no detail records on that page?

created 13 years ago

I have a report where the report footer bleeds over to the last (empty page) forcing the PageHeader to print on the last empty (except for the report footer) page.
I've tried the following without success:
void PageFooter_BeforePrint(object sender, EventArgs e) {
   object row = this.GetCurrentRow();
   if (row == null)
        e.Cancel = true;
}
This does not work since row is never null.
I've tried setting PageHeader.PrintOn to NotWithReportFooter - this does not work also because it separates the PageHeader from ReportFooter always - not what I want.
I did the following, which does work:
private int rowCounter = 0;
            Detail.AfterPrint += (o, args) => { rowCounter++; };
            PageHeader.BeforePrint += (o, args) =>
            {
                if (rowCounter >= this.RowCount)
                    args.Cancel = true;
            };
but it's a hack and real ugly.
Please tell me there is a better way to handle this.

Comments (2)
CO CO
Chris Oertling 7 years ago

    I need this.  Where did you put the code that works? In PageFooter_BeforePrint?

    DevExpress Support Team 7 years ago

      Hello,
      To process your inquiry in the most efficient manner, I've created a separate ticket on your behalf (T631067: How to hide the page footer if there are no detail records on a page). It has been placed in our processing queue and will be answered shortly.

      Answers approved by DevExpress Support

      created 13 years ago (modified 11 years ago)

      Hello Robert.
      Thank you for your message. I am afraid there is no other way to find out whether the last page contains detail data. Thus, your approach is correct, and I see no problems with using it.
      Please feel free to contact us if you have any questions regarding our controls. We will do our best to find a solution for you.
      Best regards,
      Ingvar.

        Comments (2)

          Using this method, I've found that if just one detail row falls onto the last page the page header will not be displayed. Do we have a better solution for this issue yet?

          DevExpress Support Team 11 years ago

            Hello Nathan,
            Would you please create a new ticket and provide us with a small sample illustrating your issue in action? We will examine it and do our best to help you.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.