Solved

Printing selected row from dbgrid

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now