Back to Devexpress

TdxReport.OnLayoutChanged Event

vcl-dxreport-dot-tdxreport-de3debac.md

latest3.6 KB
Original Source

TdxReport.OnLayoutChanged Event

Allows you to save report layout changes made in the Report Designer dialog.

Declaration

delphi
property OnLayoutChanged: TdxReportNotifyEvent read; write;

Remarks

The TdxReport component generates report documents based on an XML-based report definition (template) in the REPX format. A REPX report definition contains report controls, properties, and data bindings. You can use the Layout property to access the current report layout.

Handle the OnLayoutChanged event to execute custom code in response to report layout updates. For example, you can update the layout state in a custom storage every time the layout changes as demonstrated in the following code example: Save Report Layout Changes to a File.

Event Occurrence

The OnLayoutChanged event occurs in response to every Layout property value change.

Event Parameter

The ASender parameter provides access to the TdxReport component that raised the OnLayoutChanged event.

Code Examples

Save Report Layout to File on Every Change

The following code example saves the current report to a REPX file every time a user saves pending changes in the Report Designer dialog:

delphi
uses
  dxReport; // Declares the TdxReport class
// ...

procedure TMyForm.dxReport1LayoutChanged(ASender: TdxReport);
begin
  ASender.Layout.SaveToFile(ASender.ReportName + '.repx');
end;
cpp
#include "dxReport.hpp" // Declares the TdxReport class

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

void __fastcall TMyForm::dxReport1LayoutChanged(TdxReport *ASender)
{
  ASender->Layout->SaveToFile(ASender->ReportName + ".repx");
}

Save Report Layout to Database on Every Change

The following code example saves the current report to an existing BLOB dataset field every time a user saves pending changes in the Report Designer dialog:

delphi
uses
  dxReport, // Declares the TdxReport class
  dxmdaset; // Declares the TdxMemData class and related types
// ...

procedure TMyForm.dxReport1LayoutChanged(ASender: TdxReport);
begin
  dxMemData1.Edit;
  dxMemData1.FieldByName('TemplateName').AsString := ASender.ReportName;
  dxMemData1.FieldByName('TemplateLayout').Assign(ASender.Layout);
  dxMemData1.Post;
end;
cpp
#include "dxReport.hpp" // Declares the TdxReport class
#include "dxmdaset.hpp" // Declares the TdxMemData class and related types

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

void __fastcall TMyForm::dxReport1LayoutChanged(TdxReport *ASender)
{
  dxMemData1->Edit();
  dxMemData1->FieldByName("TemplateName")->AsString = ASender->ReportName;
  dxMemData1->FieldByName("TemplateLayout")->Assign(ASender->Layout);
  dxMemData1->Post();
}

See Also

TdxReport.OnPrintPreview Event

TdxReport Class

TdxReport Members

dxReport Unit