Skip to main content
A newer version of this page is available. .

How to: Use Modifiers of BrickGraphics

  • 3 minutes to read

This example demonstrates how to use report modifiers. To get more information on modifiers, refer to the Document Sections topic. We are going to create a sample report containing Detail, DetailHeader and MarginalHeader sections.

  1. Start a new Windows Application project in Visual Studio.NET.
  2. Add the PrintingSystem component to a project.
  3. Initiate report creation.

    
    using DevExpress.XtraPrinting;
    // ...
    
        BrickGraphics graph = printingSystem1.Graph;
    
        // Start the report generation.
        printingSystem1.Begin();
    
  4. To create the MarginalHeader section, set the BrickGraphics.Modifier property of the BrickGraphics to MarginalHeader. The following code adds the date, page count and the current page number to the section.

        // Set the modifier - specify the page area.
        graph.Modifier = BrickModifier.MarginalHeader;
    
        string format = "Page {0} of {1}";
        graph.Font = graph.DefaultFont;
        graph.BackColor = Color.Transparent;
        RectangleF r = new RectangleF(0, 0, 0, graph.Font.Height);
    
        // Create a brick.
        PageInfoBrick brick = graph.DrawPageInfo(PageInfo.NumberOfTotal, 
            format, Color.Black, r, BorderSide.None);
    
        brick.Alignment = BrickAlignment.Far;
        brick.AutoWidth = true;
    
        // Create another brick with different alignment.
        brick = graph.DrawPageInfo(PageInfo.DateTime, "{0:MMMM dd}", 
            Color.Black, r, BorderSide.None);
    
  5. To create a DetailHeader section, set the BrickGraphics.Modifier property of the BrickGraphics to DetailHeader. The following code adds a column caption to the section.

        // Change the page area - set the modifier.
        printingSystem1.Graph.Modifier = BrickModifier.DetailHeader;
    
        graph.BackColor = Color.Silver;
    
        // Create a brick.
        printingSystem1.Graph.DrawString("Report Items", Color.Black, 
            new RectangleF(0, 0, 200, 20), BorderSide.All);
    
  6. To create a Detail section, set the BrickGraphics.Modifier property of the BrickGraphics to Detail. The following code adds 100 numbered items to the section.

        // Change the page area - set the modifier.
        printingSystem1.Graph.Modifier = BrickModifier.Detail;
    
        graph.BackColor = Color.White;
    
        // Create bricks.
        for (int i = 0; i < 100; i++)
            printingSystem1.Graph.DrawString("Item N" + Convert.ToString(i + 1), 
                Color.Black, new RectangleF(0, 20 * i, 200, 20), BorderSide.All);
    
  7. Finish report creation by calling the PrintingSystemBase.End method, and show the Preview form to ensure that everything has been done correctly.

    
    printingSystem1.End();
        printingSystem1.PreviewFormEx.Show();
    

    The resulting report is shown in the following image.

    UseModifiers

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E119.

See Also