Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxPrintDevice.PrinterCount Property

Returns the number of available printers.

#Declaration

Delphi
property PrinterCount: Integer read;

#Property Value

Type Description
Integer

The number of available printers available in the operating system.

#Remarks

You can use the PrinterCount property value to identify the following:

  • The maximum PrinterIndex property value (PrinterCount minus 1).
  • The number of printer names accessible through the Printers property.
  • The number of objects accessible through the PrinterInfos property.

#Code Example: Change the Active Printer

The following code example sets Microsoft XPS Document Writer as the active printer device for TdxComponentPrinter:

uses
  dxPrnDev;  // This unit declares the dxPrintDevice function

// ...
var
  I: Integer;
begin
  for I := 0 to dxPrintDevice.PrinterCount - 1 do
  begin
    if dxPrintDevice.Printers.Strings[I] = 'Microsoft XPS Document Writer' then
    begin
      dxPrintDevice.PrinterIndex := I;  // Changes the active printer device
      break;
    end;
  end;
end;
See Also