ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Working with C1MultiDocument > Creating and Previewing a C1MultiDocument File

Creating and Previewing a C1MultiDocument File

To add an item to the C1MultiDocumentItemCollection, you can use the Add method. To load a file into the C1MultiDocument component you can use the Load method. To remove a file, you would use the Clear method. This method clears any file previously loaded into the C1MultiDocument component.

To add an item to the C1MultiDocumentItemCollection, you can use the Add method. Complete the following steps:

1.   In Design View, double-click on the form to open the Code Editor.

2.   Add the following code to the Load event:

      Visual Basic

Dim ppc As New C1PrintPreviewControl

Controls.Add(ppc)

ppc.Dock = DockStyle.Fill

Dim pdoc As New C1PrintDocument

Dim pdoc2 As New C1PrintDocument

Dim mdoc As New C1MultiDocument

pdoc.Body.Children.Add(New C1.C1Preview.RenderText("Hello!"))

pdoc2.Body.Children.Add(New C1.C1Preview.RenderText("World!"))

mdoc.Items.Add(pdoc)

mdoc.Items.Add(pdoc2)

ppc.Document = mdoc

mdoc.Generate()

      C#

C1PrintPreviewControl ppc = new C1PrintPreviewControl();

Controls.Add(ppc);

ppc.Dock = DockStyle.Fill;

C1PrintDocument pdoc = new C1PrintDocument();

C1PrintDocument pdoc2 = new C1PrintDocument();

C1MultiDocument mdoc = new C1MultiDocument();

pdoc.Body.Children.Add(new C1.C1Preview.RenderText("Hello!"));

pdoc2.Body.Children.Add(new C1.C1Preview.RenderText("World!"));

mdoc.Items.Add(pdoc);

mdoc.Items.Add(pdoc2);

ppc.Document = mdoc;

mdoc.Generate();

This code loads two C1PrintDocuments into the C1MultiDocument component and displays the documents in a C1PrintPreviewControl at run time.


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