Back to Devexpress

TdxPrintDialog.Execute Method

vcl-dxprndlg-dot-tdxprintdialog-fed40ff9.md

latest2.7 KB
Original Source

TdxPrintDialog.Execute Method

Displays the Print dialog.

Declaration

delphi
function Execute: Boolean;

Returns

TypeDescription
BooleanTrue

If a user closed the Print dialog and confirmed pending changes.

Tip

A click on the Print button within the displayed dialog has no predefined effect. Call custom print-related commands in your code if the Execute function returns True (as demonstrated in the code example below).

FalseIf a user closed the Print dialog and discarded pending changes. |

Remarks

Call the Execute function to display the custom Print dialog.

Unlike the Print dialog available for the TdxComponentPrinter component, the displayed Print dialog has no built-in print functionality. For example, the Page Setup… button is disabled if the OnPageSetup event is not handled.

Code Example: Display the Print Dialog and Print Content

The following code example displays the Print dialog and prints control content using the current report link:

delphi
uses
  dxPSCore, // Declares the TdxComponentPrinter class
  dxPrnDlg; // Declares the TdxPrintDialog component
// ...

procedure TMyForm.dxSpreadSheetShowPrintFormExecute(Sender: TObject);
begin
  if dxPrintDialog1.Execute() then // Displays the Print dialog
    dxComponentPrinter1.Print(False, nil); // Prints content using the current report link
end;
cpp
#include "dxPSCore.hpp" // Declares the TdxComponentPrinter class
#include "dxPrnDlg.hpp" // Declares the TdxPrintDialog component

// Add the following linker directives to the corresponding CPP source file:
#pragma link "dxPSCore" // Required to use dxPSCore.hpp declarations
#pragma link "dxPrnDlg" // Required to use dxPrnDlg.hpp declarations

void __fastcall TMyForm::dxSpreadSheetShowPrintFormExecute(TObject *Sender)
{
  if(dxPrintDialog1->Execute()) // Displays the Print dialog
    dxComponentPrinter1->Print(false, nullptr); // Prints content using the current report link
}

See Also

TdxPrintDialog.OnPageSetup Event

TdxPrintDialog Class

TdxPrintDialog Members

dxPrnDlg Unit