Solved

Printing selected row from dbgrid

Posted on 2006-10-23
2
343 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 91
Delphi Yen format 3 58
Moving (cutting/pasting) controls in a TTabbedNotebook... 7 47
Get weeknumber and year from date 4 25
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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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