ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Printing and Previewing Task-Based Help > Adding Outline Entries to the Outline Tab

Adding Outline Entries to the Outline Tab

To add outline entries to the Outline tab, use the OutlineNodeCollection.Add method.

1.   From the Toolbox, add the C1PrintPreviewControl and C1PrintDocument controls to your project.

2.   Click C1PrintPreviewControl1 to select it and in the Properties window set its Document property to C1PrintDocument1.

3.   Add the following code to the Form_Load event:

      Visual Basic

' Make the document.

MakeDoc()

 

' Generate the document.

Me.C1PrintDocument1.Generate()

      C#

// Make the document.

MakeDoc();

 

// Generate the document.

this.c1PrintDocument1.Generate();

4.   Add the MakeDoc subroutine, which uses the OutlineNodeCollection.Add method to add outline entries to the Outline tab:

      Visual Basic

Private Sub MakeDoc()

 

    ' Create RenderText1.

    Dim rt1 As New C1.C1Preview.RenderText

    rt1.Text = "This is RenderText1."

 

    ' Add an outline entry point for RenderText1.

    Me.C1PrintDocument1.Outlines.Add("RenderText1", rt1)

 

    ' Insert a page break.

    rt1.BreakAfter = C1.C1Preview.BreakEnum.Page

 

    ' Create RenderText2.

    Dim rt2 As New C1.C1Preview.RenderText

    rt2.Text = "This is RenderText2."

 

    ' Add an outline entry point for RenderText2.

    Me.C1PrintDocument1.Outlines.Add("RenderText2", rt2)

 

    ' Add the RenderText to the document.

    Me.C1PrintDocument1.Body.Children.Add(rt1)

    Me.C1PrintDocument1.Body.Children.Add(rt2)

End Sub

      C#

private void MakeDoc()

{

 

    // Create RenderText1.

    C1.C1Preview.RenderText rt1 = new C1.C1Preview.RenderText();

    rt1.Text = "This is RenderText1.";

 

    // Add an outline entry point for RenderText1.

    this.c1PrintDocument1.Outlines.Add("RenderText1", rt1);

 

    // Add a page break.

    rt1.BreakAfter = C1.C1Preview.BreakEnum.Page;

 

    // Create RenderText2.

    C1.C1Preview.RenderText rt2 = new C1.C1Preview.RenderText();

    rt2.Text = "This is RenderText2.";

 

    // Add an outline entry point for RenderText2.

    this.c1PrintDocument1.Outlines.Add("RenderText2", rt2);

 

    // Add the RenderText to the document.

    this.c1PrintDocument1.Body.Children.Add(rt1);

    this.c1PrintDocument1.Body.Children.Add(rt2);

}

 What You've Accomplished

The outline entries "RenderText1" and "RenderText2" are added to the Outline tab:

 

 


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