C#  •  Lay Out the Report

Listing 4. The basic format of any report must include at least a header, body, and footer section. Use Rectangle objects to lay out your reports easily. You can increase the complexity of these reports by adding more Rectangle objects.

// create the header
int headerHeight = 
   hf.GetHeight(ev.Graphics);
RectangleF header = new 
   RectangleF(leftMargin, topMargin, 
      pageWidth, headerHeight);

// create the footer
int bodyFontHeight = 
   bodyFont.GetHeight(ev.Graphics);
RectangleF footer = new  
   RectangleF(leftMargin, body.Bottom, 
      pageWidth, bodyFontHeight);
// create the body section
RectangleF body = new 
   RectangleF(leftMargin, header.Bottom, 
      pageWidth, pageHeight - 
      bodyFontHeight);