Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Printing checked items out of Checklistbox (Delphi 2009)

edited December 2010 in General
Hi Guys,
I want to know, how to print all checked items of an CheckListBox in Delphi

Info:
AdsConnection --> AdsQuery --> DataSource --> ppDBPipeline --> ppReport
--> ppDesigner

Delphi-Quellcode:
AdsQuery.SQL.Text:=
SELECT
p.Name,
p.Vorname,
p.PIN,
abt.Bezeichnung,
p.Passiv,
pz.Austritt,
F.Bezeichnung,
F.Zusatz,
F.Strasse,
F.Plz, F.Ort, p.ID,
bd.Bild
From Personal p
Left Outer Join Personalzusatz pz on p.ID = pz.Id_Personal
Left Outer Join Abteilungen abt on p.ID_Abteilungen = abt.Id
Left Outer Join Firma F on p.ID_Firma = F.Id
Left Outer Join Bilddatenbank bd on bd.ID_Personal = p.id
Where IFNULL(Passiv,false) = false
Order By P.name

This Query, creates new items in the Checklistbox.


procedure TfrmAusweisdruck.FormShow(Sender: TObject);
var
sName: String;
begin
frmAusweisdruck.ClientWidth := 357;
btnAusblenden.Enabled := False;
with qMitarbeiter do
begin
Active:=True;
while not Eof do
begin
sname := FieldByName('name').AsString + ', ' +
FieldByName('Vorname').AsString;

chlistboxMitarbeiter.Items.AddObject(sName,TObject(FieldByName('id').AsInteger));
Next;
end;
end;
end;

Actually, all items out of the Checklistbox will be print out,
immaterial if the items are checked or not.


procedure TfrmAusweisdruck.bitbtnDruckenClick(Sender: TObject);
begin
ppReport1.Print;
end;

But I want, that only the items will be print, who have been checked.

Comments

  • edited December 2010

    If I understand correctly you have a query that is used to load items to a
    Delphi CheckListBox and you want a report to list the checked items.

    One approach might be to populate a ClientDataSet with the query records.
    And write some code to delete records that correspond to the unchecked
    items. Connect the report to the ClientDataSet.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2010
    Also, check out demo 112 (dm0112.pas) in the \Demos\ReportsDemo.dpr. The
    example shows how to use the dataPipeline bookmark traversal feature - that
    would probably be a simpler solution.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2010
    Op 21-12-2010 17:27, Nard Moseley (Digital Metaphors) schreef:
    Also check out this page, if you use the exact same query, you can get
    the bookmarks of the dataset you use for the checkboxlist, and then put
    those bookmarks on the query in RB.
    http://www.digital-metaphors.com:8080/Data_Access/Fundamentals/Controlling_Which_Records_are_Printed
  • edited January 2011
    Am 22.12.2010 09:01, schrieb Geerten Doornenbal:
    Hi Guys,
    my solution:

    procedure TfrmAusweisdruck.ppReport1BeforePrint(Sender: TObject);
    var
    sFilter: String;
    ichecked: Integer;
    begin
    sFilter := '';
    for ichecked := 0 to chlistboxMitarbeiter.Count - 1 do
    if chlistboxMitarbeiter.Checked[ichecked] then
    begin
    if sFilter <> '' then sFilter := sFilter + ' or ';
    sFilter := sFilter + 'ID = ' +
    IntToStr(Integer(chlistboxMitarbeiter.Items.Objects[ichecked]));
    end;
    if sFilter <> '' then
    begin
    qMitarbeiter.Filter := sFilter;
    qMitarbeiter.Filtered := True;
    end;
    end;

    Thanks for helping me !
This discussion has been closed.