Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing selected row from dbgrid

Posted on 2006-10-23
2
Medium Priority
?
369 Views
Last Modified: 2010-04-05
Hi.

How can i print one row only from a dbgrid?

Thank you.
0
Comment
Question by:CodedK
2 Comments
 
LVL 9

Accepted Solution

by:
sun4sunday earned 500 total points
ID: 17787267
You can do this with a report like Quick Report, Rave Report etc.

sun4sunday
0
 
LVL 28

Assisted Solution

by:TName
TName earned 500 total points
ID: 17787310
Or you can try something like this - it will print the selected row (needs some formatting though... ;)

procedure TForm1.Button1Click(Sender: TObject);
var
PrintFile : TextFile;
tempStr, OldFont : String;
i:Integer;
begin
  Printer.PrinterIndex := -1;
  OldFont := Printer.Canvas.Font.Name;
  Printer.Canvas.Font.Name := 'Courier New';
  AssignPrn(PrintFile);
  try
     Rewrite(PrintFile);
     Writeln(PrintFile, ' ');
     tempStr:=' ';
     for i:=0 to dbgrid1.DataSource.DataSet.FieldCount-1 do begin
       tempStr:=tempStr+dbgrid1.DataSource.DataSet.Fields[i].Text;
       tempStr:=tempStr+' ';
     end;
     Writeln(PrintFile, tempStr);
  finally
    CloseFile(PrintFile);
    Printer.Canvas.Font.Name := OldFont;
  end;
end;
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Loops Section Overview
Suggested Courses

972 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