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.
- Start a new Windows Application project in Visual Studio.NET.
- Add the PrintingSystem component to a project.
Initiate report creation.
using DevExpress.XtraPrinting; // ... BrickGraphics graph = printingSystem1.Graph; // Start the report generation. printingSystem1.Begin();
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);
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.
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);
Finish report creation by calling the PrintingSystemBase.End method, and show the Preview form to ensure that everything has been done correctly.
The resulting report is shown in the following image.