There is one status property and one status event associated with the LinePrinter:
This is the page number of the report that is currently being sent to the printer. This does not imply that it is the page currently printing as the printer may buffer pages in memory before printing.
public uint PageNumberRead
Read only property.
Example:
lp.Write(string.Format("This is the Header for page {0} of the report", lp.PageNumber));
This event may be fired many times as needed during the printing of a report to communicate changes in the status. The StatusMessageEventEx will pass as a parameter one of several StatusMessageTypes telling of the current status of the report print job.
The StatusMessageTypes are defined as:
public enum StatusMessageTypes :int
The next table lists the different StatusMessageTypes that may be sent.
Status Type | Meaning |
---|---|
SM_NONE | Used when no value is specified (for example, in the fatal code for non-NPCP errors). |
SM_WRITEINCOMPLETE | Sent when the LinePrinter tried to write a line but the whole line was not written. |
SM_STARTDOC | Sent when the document starts printing. |
SM_STARTPAGE | Sent whenever printing starts on a new page. |
SM_ENDPAGE | Sent after the last line on a page prints. |
SM_ENDDOC | Sent after the last line of the last page is printed but before the LinePrinter is closed. |
SM_USERCANCEL | Passed when the user has selected to cancel printing. |
SM_CANCEL | Passed when the LinePrinter has determined the printing should be cancelled. |
SM_FINISHED | Passed after the LinePrinter has been closed without regard to the validity of the report. |
SM_COMPLETE | Passed after a report has been completely printed without cancel or errors. |
Example:
LinePrinter.StatusMessageEventEx += new LinePrinter.StatusMessageEventHandler(DisplayStatus);
A sample StatusMessageEvent handler function might have this form:
public void DisplayStatus(object source, LinePrinter.StatusMessageArgs Status) { string temp; switch (Status.MessageType) { case LinePrinter.StatusMessageTypes.SM_NONE : temp = "NONE"; break; case LinePrinter.StatusMessageTypes.SM_WRITEINCOMPLETE : temp = "WRITEINCOMPLETE"; break; case LinePrinter.StatusMessageTypes.SM_STARTDOC : temp = "STARTDOC"; break; case LinePrinter.StatusMessageTypes.SM_STARTPAGE : temp = "STARTPAGE"; break; case LinePrinter.StatusMessageTypes.SM_ENDPAGE : temp = "ENDPAGE"; break; case LinePrinter.StatusMessageTypes.SM_ENDDOC : temp = "ENDDOC"; break; case LinePrinter.StatusMessageTypes.SM_USERCANCEL : temp = "USERCANCEL"; break; case LinePrinter.StatusMessageTypes.SM_CANCEL : temp = "CANCEL"; break; case LinePrinter.StatusMessageTypes.SM_FINISHED : temp = "FINISHED"; break; case LinePrinter.StatusMessageTypes.SM_COMPLETE : temp = "COMPLETE"; break; default: temp = "UNKNOWN"; break; } StatusBox.Text += "Status " + temp + "\r\n"; }
Next » Print Routine: Clean Up Resources
Back « Print Routine: Set Up to Print