whedhoest
asked on
building report at run time...
How to make report with quickreport in delphi 3 at run time ? Because I want to make report application that generate report which have colomn that equal with fields that selected in SQL command. Can I make TQRDBText component at run time and access all of TQRDBText's properties ? Please, help me.. thank you very much..
Hi whedhoest,
It's posible to create a TQRDBText component at runtime.
Something like this will get you started
var
qrSomeField :TQRDBText;
begin
qrSomeField := TQRDBText.Create(nil);
qrSomeField.Dataset := yourDataset;
qrSomeField.Datasource := yourDatasource;
...........
...........
qrSomeField := nil;
end;
Sorry don't have the time right now to work this out in more detail, but this should get you in the right direction.
PS. if you like I will give it a better look at the other side of the day.
It's posible to create a TQRDBText component at runtime.
Something like this will get you started
var
qrSomeField :TQRDBText;
begin
qrSomeField := TQRDBText.Create(nil);
qrSomeField.Dataset := yourDataset;
qrSomeField.Datasource := yourDatasource;
...........
...........
qrSomeField := nil;
end;
Sorry don't have the time right now to work this out in more detail, but this should get you in the right direction.
PS. if you like I will give it a better look at the other side of the day.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just had a look at Whedhoest comment.
What he suggests will work except that you don't know how many columns you're going to have at design time preventing you to declare the Field variables before compiling.
The way I suggest is in essence the same at that which Whedhoest suggests except that it allows you to create as many columns as you need at runtime. In this way you don't have to know how many variables you need to declare. As a matter of fact, because of the way the QRDBText components are created ( With TQRDBText.Create(Self) do begin) and accessed at a later stage
(With FindComponent('WhatEverThe NameOfTheC omponentIs ') do) you don't have to declare variables at all to store the component into.
The method used here makes it totally dynamic which is exactly what you are looking for.
What he suggests will work except that you don't know how many columns you're going to have at design time preventing you to declare the Field variables before compiling.
The way I suggest is in essence the same at that which Whedhoest suggests except that it allows you to create as many columns as you need at runtime. In this way you don't have to know how many variables you need to declare. As a matter of fact, because of the way the QRDBText components are created ( With TQRDBText.Create(Self) do begin) and accessed at a later stage
(With FindComponent('WhatEverThe
The method used here makes it totally dynamic which is exactly what you are looking for.
Need to correct the code I submitted in the answer:
Because FindObject return a TObject you will need to typecast the result to be able to get access to it's properties
Examle for the above code:
With TQRDBText(FindComponent('W hatEverThe NameOfTheC omponentIs ')) do begin
Visible := False;
end;
AND
With TQRDBText(FindComponent('q r_' + WhatEverTheFieldNameIs)) do begin
Free;
end;
Because FindObject return a TObject you will need to typecast the result to be able to get access to it's properties
Examle for the above code:
With TQRDBText(FindComponent('W
Visible := False;
end;
AND
With TQRDBText(FindComponent('q
Free;
end;
ASKER