PrintDocument for WinForms | ComponentOne
In This Topic
    Page Footer
    In This Topic

    This topic demonstrates how to create a table footer that is divided into two columns. The following key points are shown in this topic:

    Note: The sample code fragments in this topic assume that the "using C1.C1Preview;" directive (in C# syntax; or an equivalent for other languages) has been inserted into the file, so that instead of fully qualified type names (such as C1.C1Preview.RenderText) we can use just the class name part (RenderText).

    Complete the following steps to create a table footer with two parts:

    1. Create a new Windows Forms application.
    2. From the Toolbox, add a C1PrintPreview control onto your form. Add a C1PrintDocument component onto your form, it will appear in the components' tray below the form. The preview will have the default name C1PrintPreview1, the document C1PrintDocument1.
    3. Set the value of the Document property of C1PrintPreview1 control to C1PrintDocument1, so that the preview will show the document when the application runs.
          
    4. Double click the form to switch to code view and create a handler for the Form_Load event. In the Form_Load event, we will set up our document.
    5. Add the following code to the Form_Load event to create a RenderTable for the page footer and add a table with 4 columns, 100 rows, and sample text:
    6. Add the following code to set the font type to Arial, 10 points and the background color to lemon chiffon:

      Here we reserved the last two rows of the page for the footer using the Count property and grouped the rows together using the RowGroups property. We then assigned a new font style for the text and a new background color for the cells in our page footer.

    7. Next, we'll use the TextAlignHorz and TextAlignVert properties to set the alignment of the text in each column of the page footer. We'll span the footer over the last two rows and create two columns using the SpanRows and SpanCols properties. We will draw the text into each column of the table for the page footer. Finish by using the Generate method to create the document.

    Run the program and observe the following:

    Your new page footer with two parts should appear to the footer below: