Reports for WinForms | ComponentOne
In This Topic
    Setting the Page Size
    In This Topic

    To set the page size for the document, use the PaperKind property.

    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:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      ' Make the document.    
      MakeDoc()
      
      ' Generate the document.    
      Me.C1PrintDocument1.Generate()
      

      To write code in C#

      C#
      Copy Code
      // Make the document.    
      MakeDoc();
      
      // Generate the document.    
      this.c1PrintDocument1.Generate();
      
    4. Add the following MakeDoc subroutine, which uses the PaperKind property to set the page size to Legal:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Private Sub MakeDoc()
      
          ' Define the page layout for the document.    
          Dim pl As New C1.C1Preview.PageLayout()    
          pl.PageSettings = New C1.C1Preview.C1PageSettings()    
          pl.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Legal    
          Me.C1PrintDocument1.PageLayouts.Default = pl    
      End Sub
      

      To write code in C#

      C#
      Copy Code
      private void MakeDoc()    
      {
      
          // Define the page layout for the document.    
          C1.C1Preview.PageLayout pl = new C1.C1Preview.PageLayout();    
          pl.PageSettings = new C1.C1Preview.C1PageSettings();    
          pl.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Legal;   
          this.c1PrintDocument1.PageLayouts.Default = pl;    
      }
      

      What You've Accomplished

      The default page size is set to Legal: