Spread Windows Forms 7.0 Product Documentation
PrintDocument Event
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > FpSpread Class : PrintDocument Event


Glossary Item Box

Occurs when printing a sheet.

Syntax

Visual Basic (Declaration) 
Public Event PrintDocument As PrintDocumentEventHandler
Visual Basic (Usage)Copy Code
Dim instance As FpSpread
Dim handler As PrintDocumentEventHandler
 
AddHandler instance.PrintDocument, handler
C# 
public event PrintDocumentEventHandler PrintDocument

Event Data

The event handler receives an argument of type PrintDocumentEventArgs containing data related to this event. The following PrintDocumentEventArgs properties provide information specific to this event.

PropertyDescription
Cancel Gets or sets whether to cancel the print process. Note: Cancelling the print process cannot be reversed.
CurrentPage Gets the order number of the current printed page.
EventType Gets the type of PrintDocument event.
PrintAction Gets the PrintAction type of the PrintDocument event.
TotalPage Gets the total number of printed pages.

Example

This example uses the PrintDocument event.
C#Copy Code
private void Form1_Load(object sender, EventArgs e)
        {
    fpSpread1.Sheets.Count = 2;
    fpSpread1.Sheets[0].Cells[0, 0].Text = "Print Sheet 1";
    fpSpread1.Sheets[1].Cells[0, 0].Text = "Print Sheet 2";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            fpSpread1.PrintSheet(-1);
        }

        private void fpSpread1_PrintDocument(object sender, FarPoint.Win.Spread.PrintDocumentEventArgs e)
        {
    listBox1.Items.Add(e.CurrentPage.ToString());
    listBox1.Items.Add(e.EventType.ToString());
    listBox1.Items.Add(e.TotalPage.ToString());
    listBox1.Items.Add(e.PrintAction.ToString());
        }
VB.NETCopy Code
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    FpSpread1.PrintSheet(-1)
End Sub

Private Sub FpSpread1_PrintDocument(sender As Object, e As FarPoint.Win.Spread.PrintDocumentEventArgs) Handles FpSpread1.PrintDocument
    ListBox1.Items.Add(e.CurrentPage.ToString())
    ListBox1.Items.Add(e.EventType.ToString())
    ListBox1.Items.Add(e.TotalPage.ToString())
    ListBox1.Items.Add(e.PrintAction.ToString())
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    FpSpread1.Sheets.Count = 2
    FpSpread1.Sheets(0).Cells(0, 0).Text = "Print Sheet 1"
    FpSpread1.Sheets(1).Cells(0, 0).Text = "Print Sheet 2"
End Sub

Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8

See Also

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.