Solved

building report at run time...

Posted on 1998-12-01
5
465 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now