Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 107,329 times

Contents

Downloads

Related Categories

Printing Reports in .NET - Layouts

mag37

Layouts

Linear layout

The LinearSections class is used to print a variety of sections, one below (or next to) another. In its simplest form, the linear layout looks like the figure to the right.

Each section may consume a different amount of real-estate. Some may be as wide as the page, others may not. The LinearSections container (shown in color) is a rectangle as wide as the widest section and as tall as all sub-sections combined.

This is the simplest class to use for structuring a report. Simply start a LinearLayout with the ReportBuilder class and then add ReportSections for text and data as needed.

Example of LinearSections

Layered layout

The layered layout is for combing sections together into one region. This is often used for placing varying ReportSectionText objects together in one PageHeader or PageFooter. It could also be used to add a watermark to the body of a ReportDocument.

Example of LayeredSections

Column layout

As the name suggests, the column layout is used for creating columns on a page. A picture of a document using columns can be found on the samples page.

The column layout contains a vertical LinearSections container nested within a horizontal LinearRepeatableSections container. The vertical container has a maximum width of the column width. It renders as much of its content as possible within a column, then returns to the horizontal container. The horizontal container advances by the width of the column (plus any margin required in the middle) and repeats the call to the vertical container. This gives the parent container the name LinearRepeatableSections since it will repeat calls to a child section within a single page.

In the example shown, the LinearRepeatableSections has a special divider section assigned to it of a vertical line. This divider is printed between calls to the vertical section.

Box section

The box isn't stricly a container in the class hierarchy sense, since it doesn't inherit from SectionContainer. However, it does contain one section which can be assigned to it. And the ReportBuilder class, when it supports the SectionBox, will treat it as a container by assigning a layered or linear container to the box.

The box follows many of the properties from the W3C box model. I recommend visiting this page to learn more.

(graphic from w3.org)

The margins are set the same as for any other report section. The margins are always clear. The borders are set by specifying a System.Drawing.Pen object to use for each border. The pen object specifies color and width. The padding is specified in inches, again for each side independently.

If a background brush is set (using the System.Drawing.Brushes), it will paint the entire area inside the border (including the padding).

The width and height can each be set independently, or not at all. If the width is not specified, then the width will size to that of the contents. If the width is explictly set using the Width property, that width includes content, padding, border, and margins. The width can also be set as a percentage of the parent (using the WidthPercent property). The same is true for the Height and HeightPercent properties.

An offset can be set which moves the box in relation to the parent and normal flow. This should normally be used in LayeredLayout, as the results in LinearLayout haven't been adequately tested.

Mike Mayer is a Microsoft MVP in Visual C#.

Comments

  • Re: [4585] Printing Reports in .NET

    Posted by pericoman on 04 Mar 2007

    Fist of all you have to learn how to program, but I think it's better that you learn how to read.

  • Re: [4585] Printing Reports in .NET

    Posted by wagb278 on 08 Jul 2006

    Simple, I hope, question - What and how do I add the "Library" to my C# VS2005 project?


    I.m new to C# and VS 2005.  This is my first project.  ReportPrinting appears to be ju...

  • Which FastReport to choose?

    Posted by Ann Ivanova on 27 Jun 2005

    Borland Delphi and Borland C++Builder users often ask us, “Which report generator to choose: either FreeReport or FastReport 2.*, or FastReport 3.*?”, “Why FastReport 2 and FastReport 3 both are avail...

  • FreeReport 2.33 released!

    Posted by Ann Ivanova on 12 Apr 2005

    - added Delphi 4-7, 2005, C++Builder 4-6 support
    - added FastReport 3 (*.fr3) format support in report designer
    #????
    #????

    FreeReport is a reporting tool component. It consists of report engine...

  • Removing grid

    Posted by luisr on 15 Oct 2004


    Hello,

    By now you probably figured it out, but you have to do something like this:

    dv = dt.DefaultView;
    SectionTable st = builder.AddTable(dv, false, 100.0f);
    st.Supp...