How to add List view item into dataset in delphi?

2019-09-09 15:26发布

问题:

i am developing invoicing system

in my application there is a listview, a fastreport, button.. when press the the button the report should show the all item in the report can anyone provide best solution for this?

回答1:

From example PrintStringList from FastReport's Demos folder:

var
  Button1: TButton;
  StringDS: TfrxUserDataSet;
  frxReport1: TfrxReport;
  StringList: TStringList;

procedure TForm1.Button1Click(Sender: TObject);
begin
  StringDS.RangeEnd := reCount;
  StringDS.RangeEndCount := StringList.Count;
  frxReport1.ShowReport;
end;

procedure TForm1.frxReport1GetValue(const VarName: String; var Value: Variant);
begin
  if AnsiCompareText(VarName, 'element') = 0 then
    Value := StringList[StringDS.RecNo];
end;