Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Printing selected row from dbgrid

Posted on 2006-10-23
2
Medium Priority
?
365 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

705 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