Solved

building report at run time...

Posted on 1998-12-01
5
469 Views
Last Modified: 2010-04-04
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..
0
Comment
Question by:whedhoest
  • 3
5 Comments
 

Author Comment

by:whedhoest
ID: 1348870
Edited text of question
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1348871
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.


0
 
LVL 1

Accepted Solution

by:
Gerhard100198 earned 200 total points
ID: 1348872
This is not fully working code but it should be more than enough to get you up and going.
If you have any questions please feel free to ask.

You can also email me at gerhardvr@email.com

var
  I: Integer;
begin

  For I := 0 to NumberOfColumnsYouNeed do begin
    With TQRDBText.Create(Self) do begin
      //Now loop to create a QRDBText component for evey one of the fields in your query
      //I like to use the field name as the component name prefixed with some text, in
      //this case 'qr_'
      Name := 'qr_' + WhatEverTheFieldNameIs;
      Parent := TheFormNameItBelongsTo //Remember to set this else it won't be visible
      Top := YouCalculateTheTopPos;
      Left := YouCalculateTheLeftPos;
      ....... //You now have access to all the properties of the components
  end;

  //If you need to access any of these components at a later stage to change
  //a property you can do it in the following way
  With FindComponent('WhatEverTheNameOfTheComponentIs') do begin
     Visible := False;
  end;

  //REMEMBER TO FREE ALL THESE COMPONENTS THAT YOU HAVE CREATED
  //WHEN YOURE DONE
  For I := 0 to NumberOfColumnsYouNeed do begin
    //You have to do this for all the fields in your query since you created
    //a component for each of them
    With FindComponent('qr_' + WhatEverTheFieldNameIs) do begin
      Free;
    end;
  end;
end;
0
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1348873
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('WhatEverTheNameOfTheComponentIs') 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.
0
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1348874
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('WhatEverTheNameOfTheComponentIs')) do begin
          Visible := False;
  end;

AND

   With TQRDBText(FindComponent('qr_' + WhatEverTheFieldNameIs)) do begin
           Free;
   end;
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question