Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 03-21-2001, 01:36 AM
sammyjj20 sammyjj20 is offline
Junior Member
 
Join Date: Mar 2001
Posts: 7
Default PRINTING DBGrids.

I have this DBGrid on my form that contains information on a datasource. I need to be able to print out the information so it may be read record by record. My programing is limited and would apretiate any feedback on this matter.
Reply With Quote
  #2  
Old 03-21-2001, 05:27 AM
Scottg Scottg is offline
Senior Member
 
Join Date: Feb 2001
Posts: 109
Default RE: PRINTING DBGrids.

Sammy:

This is just about as generic as I can make it. In your button click event:

var
iRow, iCol, iRowHeight, iColWidth, i: Integer;
begin
iRow := 0;
iRowHeight := (Printer.PageHeight div 70);
Printer.BeginDoc;
while not DBGrid1.DataSource.DataSet.Eof do begin
iRow := iRow + iRowHeight;
iCol := 0;
for i := 0 to DBGrid1.FieldCount - 1 do begin
Printer.Canvas.TextOut(iCol, iRow, DBGrid1.Fields[i].AsString);
iColWidth := Printer.Canvas.TextWidth(StringofChar('X',DBGrid1. Fields[i].DisplayWidth));
iCol := iCol + iColWidth + 10;
end;
DBGrid1.DataSource.DataSet.Next;
end;
Printer.EndDoc;
end;

Hope this helps!

Scottg
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:27 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.