ComponentOne Preview Classic for WinForms: Preview Classic for WinForms Quick Start > Creating Tables in C1PrintDocument > Adding Text Below the Table in Your Document

Adding Text Below the Table in Your Document

Adding text below the table in your documents shows how to use the RenderBlockText method to render the text into the block flow. It also demonstrates how to use the AdvanceBlockFlow method to advance the block position so that the next render object (in this case, text) is rendered there. In this topic we will use the AdvanceBlockFlow to put the text 1 cm below the table in your document.

1.   The following code should already exist in your source file:

      Visual Basic

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

    ' Make a table with 3 columns and 3 rows.

    Dim table As C1.C1PrintDocument.RenderTable = New C1.C1PrintDocument.RenderTable(Me.C1PrintDocument1)

    table.Columns.AddSome(3)

    table.Body.Rows.AddSome(3)

 

    ' Generate the document.

    Me.C1PrintDocument1.StartDoc()

    Me.C1PrintDocument1.RenderBlock(table)

 

    Me.C1PrintDocument1.EndDoc()

End Sub

      C#

private void Form1_Load(object sender, System.EventArgs e)

{

    // Make a table with 3 columns and 3 rows.

    C1.C1PrintDocument.RenderTable table = new C1.C1PrintDocument.RenderTable(this.c1PrintDocument1);

    table.Columns.AddSome(3);

    table.Body.Rows.AddSome(3);

 

    // Generate the document.

    this.c1PrintDocument1.StartDoc();

    this.c1PrintDocument1.RenderBlock(table);

 

    this.c1PrintDocument1.EndDoc();

}

2.   Use the AdvanceBlockFlow method to move the block flow position down 1 centimeter by inserting the following code just before the EndDoc@C1PrintDocument.EndDoc method:

      Visual Basic

Me.C1PrintDocument1.AdvanceBlockFlow("1cm")

      C#

this.c1PrintDocument1.AdvanceBlockFlow("1cm");

3.   Use the RenderBlockText method to render the text into the block flow:

      Visual Basic

Me.C1PrintDocument1.RenderBlockText("In the table above, there are three rows and three columns.")

      C#

this.c1PrintDocument1.RenderBlockText("In the table above, there are three rows and three columns.");

Run the program and observe the following:

Your document will appear like this:

 


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.