Lesson 6 - Insert Two Rows
- 3 minutes to read
The link created in this lesson generates a document that contains two rows. The first row contains a check box brick in an unchecked state, and an empty brick. The second row is inserted to display the check box in the checked state.
To insert two rows into the content of a printing link, do the following.
To create a new printing link, declare a new class (Lesson6) derived from the Lesson5 class defined in the previous lesson. The new class overrides the CreateRow and CreateDetail methods to create two new bricks: check box and empty brick.
using System.Drawing; using System.Windows.Forms; using DevExpress.XtraPrinting; // ... public class Lesson6 : Lesson5 { public Lesson6(PrintingSystem ps) : base(ps) {} protected override void CreateDetail(BrickGraphics graph) { // Center the text string. graph.StringFormat = graph.StringFormat.ChangeLineAlignment(StringAlignment.Center); // Add an unchecked check box brick with all borders displayed // to a specific location using the Light Sky Blue background color. graph.DrawCheckBox(new Rectangle(150, 0, 50, 50), BorderSide.All, Color.LightSkyBlue, false); // Add an empty rectangle with all borders displayed // to a specific location using the Light Lavender background color. graph.DrawRect(new Rectangle(200, 0, 50, 50), BorderSide.All, Color.Lavender, graph.BorderColor); base.CreateDetail(graph); } protected override void CreateRow(BrickGraphics graph) { base.CreateRow(graph); // Add a checked check box brick with all borders displayed // to a specific location using the Light Sky Blue background color. graph.DrawCheckBox(new Rectangle(150, top, 50, 50), BorderSide.All, Color.LightSkyBlue, true); } }
Next, modify the main form’s Load event handler to pass the Printing System of the Document Viewer to the new link.
Launch the application and view the result.
See Also