Recent

Author Topic: [TUTORIAL] How to use clientdata in fortes report  (Read 8326 times)

nicke85

  • Jr. Member
  • **
  • Posts: 92
  • #13#10
[TUTORIAL] How to use clientdata in fortes report
« on: May 29, 2011, 12:55:49 pm »
Hi folks,

at the first to thanks Danish programer bitsmurf who helped me to find solution,
I had a bit trouble before two weeks to use parsed string list from listbox to be reported into fortesreport and I finished project with Lazreport.My project was to make barcode generator which retrieve data from MSSQL and to strip it into numbers to be used for barcodes (code39).Barcodes are printed into form:

bc1 bc2
bc3 bc4
bc5 etc.. on SATO CX400 printer

After i asked many brasilian programmers who works with fortes.They didn't help me to find solution how to use clientdata from Listbox items to be shown into report without SQL connection.
Actually one man told me that it is imposible to do grrrrrrrr  >:D

To be clean my steps were:
1.Connect to SQL Database
2.Retreave data from database
3.Disconect from SQL Database
4.Fill Listbox1 with data
5.Perform Listbox2 with data from listbox1 which is going to be printed

at the end i have Listbox2 which is copy and strip from ListBox1 (array of strings).

To make fortes to use clientsdata you only need one counter and nothing else for variables.

Quote
1. Make two forms on your projects
2. Make referencial units on each other
 on unit1 write into implementation
Code: [Select]
Implementation
  uses unit2;
 and on unit2 write
Code: [Select]
Implementation
  uses unit1;

3. on unit1 (form1) put your listbox or edit1 or label or memo components which will be used for data source in report and put one button which will be used to call report

4. On form2 put RLReport than RLDetailGrid and put anythiing you want for components into
   RLDetailGrid (eg. RLcaption,Memo,etc..) and make transparent option for every component to be
   FALSE

5. For RLDetailGrid i put options in object inspector ColCount=2,Height=89 and Width=300 but you
   can perform like you want

6. In unit1 (mainform) set event button1click to be Form2.RLReport1.Preview;

7. In Unit2 (report unit) set global variable Counter insted main var and set to 0
  
Code: [Select]
var
  Form1: TForm1;
  Counter: Integer = 0;

8. Make on RLReport1 event OnNeedData and define MoreData and objects source like in code below
  
Code: [Select]
procedure TForm1.RLReport1NeedData(Sender: TObject; var MoreData: boolean);
 begin
    MoreData:= Counter < MainForm.ListBox1.Items.Count;
    if MoreData then
    begin
       MyBarcode.Caption := MainForm.ListBox1.Items[Counter];
       RLMemo1.Lines.Text := MainForm.Edit1.Text;
       Inc(Counter);
    end else Counter:=0;
 end;

9. That is actually all :D
  counter and one procedure

Demo is in this post.I hope it will help someone  O:-) :)
« Last Edit: May 29, 2011, 10:04:48 pm by nicke85 »
ArchLinux X64 (XFCE) & Windows 7 SP1 Ultimate X64
FPC 2.7.1 / Lazarus 1.1 / ZeosDBO / fortes4lazarus -- all svn

carlosmoura

  • Newbie
  • Posts: 4
Re: [TUTORIAL] How to use clientdata in fortes report
« Reply #1 on: September 05, 2017, 03:52:49 pm »
Very good. Thanks!

 

TinyPortal © 2005-2018