Solved

print dbgrid contents

Posted on 2001-07-14
6
337 Views
Last Modified: 2010-04-06
I need to print all dbgrid contents. How can I do this?

thanks.
0
Comment
Question by:pin_plunder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Expert Comment

by:jsweby
ID: 6282421
I don't know of a solution for the standard DBGrid, but you can get an advanced DBGrid from TMS Software (free is it isn't for commerical use) at www.tmssoftware.com which has a host of printing capabilities.

J.
0
 

Author Comment

by:pin_plunder
ID: 6282615
umm. I would prefer to do it with the standard dbgrid. maybe some report would help here, but I don't have the least idea of how to use them.

thanks
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6283068
listening
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
nnbbb09 earned 50 total points
ID: 6283260

There is a component at http://www.orbital.co.za that can print a dataset. Might be worth a try.
There are also some components at http://www.torry.net that claim to be able to print a dbgrid. Just enter "print dbgrid" in the search page.

Jo
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6283360
I agree with the above commenters: A component to do this is more efficient, but here are the steps to using the QuickRep Components. Obviously you'll have to do some massaging, but the general idea is here:

Step to printing table information that you see in a DBGRID
1. Create a new application.
2. Add the following components to the form: TDatasource, TTable, TDBGrid, TButton.
3. Set FormStyle to fsMDIForm.
4. Set Table1 DatabaseName to DBDEMOS
5. Set Table1.Name to clients.dbf
6. Set Datasource1.Dataset to table1
7. Set DBGrid1.Datasource to Datasource1
8. Set Table1.Active to True
9. Save Unit as ...CUnit1.pas
10. Create a new form.
11. Set FormStyle to fsMDIChild
12. Add CUnit1 to the uses clause of the child form.
13. Save the second form as CUnit2.pas
14. Place one QuickRep component on the child form.
15. Set QuickRep.DataSet to Form1.Table1
16. Place a QRGroup1 band on the QuickRep component.

17. Place a QRDBText component inside the QRGROUP1 band for each field found on the dbGrid. Put a QRDBLabel next to each and label the appropriately.
18. Set the QRDBText.DataSet to Form1.Table1
19. Set the QRDBText.DataField to  a field from the dropdown box.
20. Save the file.
21. Open CUnit1. Beneath the word implementation add USES CUnit2.
22. From the Delphi IDE Menu Select PROJECT | OPTIONS | FORMS.
23. Move Form2 to Available Forms.
24. Click OK.
25. Open the Button1.OnClick Event add the following code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  DbGrid1.Visible := False; {Better if this is on it's on child form!}
  Button1.Visible := False; {Better if this is on the same child form that DBGrid1 is on}
  Form2 := TForm2.Create(Self);
  Form2.Show;
end;
26. Save the file.
27. Open Form2 OnShow Event. Add the following code:

procedure TForm2.FormShow(Sender: TObject);
begin
  QuickRep1.Preview;
end;

28. Open the Form2 OnClose Event. Add the Following Code:

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if MessageDlg('Close application ?', mtConfirmation,
    [mbYes, mbNo], 0) = mrYes then
    Action := caFree
  else
    Action := caNone;

end;

29. Open the Form2 OnDestroy Event. Add the Following:

procedure TForm2.FormDestroy(Sender: TObject);
begin
  Form1.DBGrid1.Visible := true;
  Form1.Button1.Visible := True;
  Form2.Free; {Clean up}
end;
0
 

Author Comment

by:pin_plunder
ID: 6283996
thanks everybody for your help. Specially gemarti for his complete "step by step" comments.

thanks again.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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