Reports for WinForms | ComponentOne
In This Topic
    Adding Text Below the Table in the Document
    In This Topic

    This topic shows how to use the C1.C1PrintDocument.RenderTable object to render the text into the block flow. It also demonstrates how to use the Padding property 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 Padding property to put the text 1 cm below the table in your document. This topic assumes you already have a table created.

    1. Use the C1.C1PrintDocument.RenderTable object to create the text to be displayed:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim caption As C1.C1Preview.RenderText = New C1.C1Preview.RenderText(Me.C1PrintDocument1)    
      caption.Text = "In the table above, there are three rows and three columns."
      

      To write code in C#

      C#
      Copy Code
      C1.C1Preview.RenderText caption = new C1.C1Preview.RenderText(this.c1PrintDocument1);    
      caption.Text = "In the table above, there are three rows and three columns.";
      
    2. Use the Padding property to position the text 1 cm below the table:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      caption.Style.Padding.Top = New C1.C1Preview.Unit(1, C1.C1Preview.UnitTypeEnum.Cm)
      

      To write code in C#

      C#
      Copy Code
      caption.Style.Padding.Top = new C1.C1Preview.Unit(1, C1.C1Preview.UnitTypeEnum.Cm);
      
    3. Add the text below the table using the Add method. Insert the Add method for the text below the Add method for the table, as shown in the following code:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.C1PrintDocument1.Body.Children.Add(table)    
      Me.C1PrintDocument1.Body.Children.Add(caption)
      

      To write code in C#

      C#
      Copy Code
      this.c1PrintDocument1.Body.Children.Add(table);    
      this.c1PrintDocument1.Body.Children.Add(caption);
      

      Note: Placing the Add method for the text below the Add method for the table inserts the text below the table. If it is placed above the Add method for the table, the text will appear above the table.

    Run the program and observe the following:

    Your document should appear similar to the document below: