Solved

Printing selected row from dbgrid

Posted on 2006-10-23
2
347 Views
Last Modified: 2010-04-05
Hi.

How can i print one row only from a dbgrid?

Thank you.
0
Comment
Question by:CodedK
[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
2 Comments
 
LVL 9

Accepted Solution

by:
sun4sunday earned 125 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 125 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

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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