GrapeCity MultiRow Windows Forms Documentation
PrintPreview(Int32) Method
Example 


A System.Int32 value that indicates the maximum number of pages shown in the System.Windows.Forms.PrintPreviewDialog.
Previews the print result with the System.Windows.Forms.PrintPreviewDialog.
Syntax
Public Overloads Sub PrintPreview( _
   ByVal maxPages As Integer _
) 
Dim instance As GcMultiRow
Dim maxPages As Integer
 
instance.PrintPreview(maxPages)
public void PrintPreview( 
   int maxPages
)

Parameters

maxPages
A System.Int32 value that indicates the maximum number of pages shown in the System.Windows.Forms.PrintPreviewDialog.
Exceptions
ExceptionDescription
System.ArgumentOutOfRangeExceptionThe maxPages parameter is less than 1.
Remarks

Print, PrintPreview, and PageSetup are a set of print methods. You can use them to implement the print function. The System.Windows.Forms.PrintDialog, System.Windows.Forms.PrintPreviewDialog, and System.Windows.Forms.PageSetupDialog allow the user to set print settings. The System.Drawing.Printing.PageSettings of System.Windows.Forms.PageSetupDialog are shared for these methods.

You can change the PrintSettings property value to adjust the print effect.

Example
The following code example shows how to print GcMultiRow. Before printing the GcMultiRow control, set some PrintSettings, then execute the PrintPreview method to preview the effect, or execute the Print method to print directly to a printer. This example is part of a larger example for the GcMultiRow.PrintSettings class.
void setRichAndFlowButton_Click(object sender, EventArgs e)
        {
            Template template1 = CreateTemplate(3, 21);
            AddPrintInfoCellColumnFooterSection(template1, 21);
            this.gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 50;

            //All UI elements are printed, like UpDown button.
            gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Rich;
            //All Rows are printed from the first page to the last page, one by one.
            gcMultiRow1.PrintSettings.PagingMode = PagingMode.Flow;
            //The GcMultiRow is aligned by MiddleLeft.
            gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleLeft;
            //Between every two Rows, there are 15 pixels.
            gcMultiRow1.PrintSettings.SectionMargin = 15;
            //Only the Row from 2th to 8th are printed
            gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.SomeRows;
            gcMultiRow1.PrintSettings.FromRow = 2;
            gcMultiRow1.PrintSettings.ToRow = 8;

            if (flag)
            {
                //The Template's width is less than the page's width, set AutoFitWidth to true, the Template is zoomed out to 
// fit the page's width.
                gcMultiRow1.PrintSettings.AutoFitWidth = true;
                flag = false;
            }
            else
            {
                gcMultiRow1.PrintSettings.AutoFitWidth = false;
                flag = true;
            }
            gcMultiRow1.PrintSettings.ZoomFactor = 1f;
            try
            {
                gcMultiRow1.PrintPreview();
                //If you have a printer, execute the following code directly instead.
                //gcMultiRow1.Print(true);
            }
            catch (Exception ex)
            {
                // Can't find printer driver.
                MessageBox.Show(ex.Message);
            }
            label.Text = "In Rich style, all elements are printed, like UpDown button; Between two rows, 15 pixels exist; 
Only  the 2th to 8th row are printed one by one from page's Top to Bottom; The GcMultiRow is aligned by MiddleLeft; 
(Click the button again to view the AutoFitWidth property's effect)";
        }
Private Sub setRichAndFlowButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
setRichAndFlowButton.Click
        Dim template1 As Template = CreateTemplate(3, 21)
        AddPrintInfoCellColumnFooterSection(template1, 21)
        Me.gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 50

        'All UI elements are printed, like UpDown button.
        gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Rich
        'All Rows are printed from the first page to the last page, one by one.
        gcMultiRow1.PrintSettings.PagingMode = PagingMode.Flow
        'The GcMultiRow is aligned by MiddleLeft.
        gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleLeft
        'Between every two Rows, there are 15 pixels.
        gcMultiRow1.PrintSettings.SectionMargin = 15
        'Only the Row from 2th to 8th are printed
        gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.SomeRows
        gcMultiRow1.PrintSettings.FromRow = 2
        gcMultiRow1.PrintSettings.ToRow = 8

        If flag Then
            'The Template's width is less than the page's width, set AutoFitWidth to true, the Template is zoomed out to fit 
the page's width.
            gcMultiRow1.PrintSettings.AutoFitWidth = True
            flag = False
        Else
            gcMultiRow1.PrintSettings.AutoFitWidth = False
            flag = True
        End If
        gcMultiRow1.PrintSettings.ZoomFactor = 1.0F
        Try
            'If you have a printer, execute the following code directly instead.
            'gcMultiRow1.Print(true);
            gcMultiRow1.PrintPreview()
        Catch ex As Exception
            ' Can't find printer driver.
            MessageBox.Show(ex.Message)
        End Try
        label.Text = "In Rich style, all elements are printed, like UpDown button; Between two rows, 15 pixels exist; Only  
the 2th to 8th row are printed one by one from page's Top to Bottom; The GcMultiRow is aligned by MiddleLeft; (Click 
the button again to view the AutoFitWidth property's effect)"
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GcMultiRow Class
GcMultiRow Members
Overload List
PrintSettings Property
PrintPreview Method
PageSetup Method
PrintSettings Property
Print Method
PageSetup Method

 

 


Copyright © GrapeCity, inc. All rights reserved.