Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble printing out Dbgrid to printer

Status
Not open for further replies.

229257

Programmer
Apr 23, 2002
54
GB
I am creating a print routine to print out certain items on a form.

when i use the following command;

Printer.Print DBGrid1

It only prints out the first column of the first row.

I would like to print the contents of the whole grid.

Is this possible? Any suggestions would be greatly appreciated!

229257
 
You can not print a grid that way.

DBGrid has a default property call Text.
Text holds the value of the current grid column and selected row.
So, all you are doing is printing the text in that cell.

You will have to create your own print form, or use a DataReport and pass the recordset to it. [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
If you only want to print the visible info in the DataGrid, then you can use this (You will need to put an invisible picturebox on your form, with Autoredraw set to true, and Autosize to true.):

Picture1.Picture = DataGrid1.CaptureImage
Set Picture1.Picture = Picture1.Image
' adjust the two numbers at the end of the next line to specify where on the printer page it will print.
Printer.PaintPicture Picture1.Picture, 0, 0
Printer.EndDoc

If you have a grid that's bigger than the page you want to print on, or this format doesn't suit your needs, then you will need to do as CCLINT suggested.

Robert

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top