[Overview][Types][Classes][Variables][Index] | Reference for unit 'Printers' (#lcl)

# TPrinter.PrinterIndex

Contains the ordinal position in Printers for the selected print device.

## Declaration

Source position: printers.pas line 323

`public property TPrinter.PrinterIndex : Integer read GetPrinterIndex write SetPrinterIndex;`

## Description

PrinterIndex is an Integer property which contains the ordinal position in Printers for the selected print device. The default value for the property is -1, and indicates that a print device has not been selected and that the default printer should be used. The default printer is the first one in the Printers property.

Setting a new value in PrinterIndex causes the CheckPrinting method to be called to ensure that the value in Printing is False. An exception is raised in CheckPrinting when Printing is set to True. Set the value for the property prior to calling the BeginDoc method.

An exception may also be raised for the following conditions:

- PrinterIndex is set to a value greater than or equal to 0 and the list of Printers is empty.
- PrinterIndex is set to a value larger than the number of entries in Printers.

The SetPrinter method is called to make the named device the selected print device. DoResetFontsList is called to reload the values in the Fonts property.

## Errors

EPrinter
  Raised with the message 'Printer is printing'. Raised with the message 'No printers defined!'. Raised with the message 'Printer index out of range!'.

## See also

TPrinter.BeginDoc |  | Starts printing for the current document.
TPrinter.DoResetFontsList |  | Performs actions needed to reset the list of Fonts for the selected printer.
TPrinter.Fonts |  | the list of available Fonts for the current printer.
TPrinter.Printing |  | True if the document is currently being printed.
TPrinter.Printers |  | Contains the names for devices that can be selected for printing.
TPrinter.SetPrinter |  | Makes the device with the specified name the current printer.
EPrinter |  | Exception raised for errors in TPrinter methods.