How To…Refresh the Report After a Drawcommand Click

Question

“How can I refresh/redraw the report after I click a “hot” component on my report?”

Solution

Inside the OnDrawCommandClick event of a report component, reset the report and report engine.  Then set the DrawCommand.RedrawPage property to True. This is very similar to the way the AutoSearch feature functions and can also be done with RAP code using a small passthru function.

Download:

RefreshReportAfterDataChange.zip
RefreshReportAfterDataChangeRAP.zip 

Sample Delphi code:

uses
  ppDrwCmd;

procedure TForm1.ppLabel1DrawCommandClick(Sender, aDrawCommand: TObject);
begin

  //Make changes to the report/dataset here...

  ppReport1.Reset;
  ppReport1.Engine.Reset;
  TppDrawText(aDrawCommand).RedrawPage := True;

end;