problems with printing a dbgrid

I am trying to print the data and column header in a dbgrid by using the printer.print (rowdata),but since the column header contains more characters than the column data therefore they get all mixed up ie. I am trying to print the dbgrid like MS Excel sheet (without the grid) with each column data under its corresponding column header. I tried to use vbtab and adding spaces but it still did not work.

So is there a way in VB5 to print the data in dbgrid with its column headers in a nice format?

Who is Participating?

If you use the DrawText API, you can create a bounding box for each text field that you send to the printer. You can specify word wrapping in this box, and it will automatically wrap the words for you.

Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type DOCINFO
cbSize As Long
lpszDocName As String
lpszOutput As String
End Type

Here's my suggestion. I am assuming yu have a data control on your form with the records you have, because you probably bound it to the data control

Add a crystal report control to your form. Set the ReportSource = 3, set the datasource = data1 or whatever teh data control is.

when you want the report, just sset the action property of the crystal control to 1, and it will print the recordset. With Crystal Reports Pro (I dont have it) you can actually do this same method with the data grid itself.

if I use the printer.currentX= then I have to truncate some column headers, in order to fit all data (because the number of columns headers is greater than the width of the page) or I may
need to change the page orientation to landscape at run time (which I don't know how)and if the user insists on portrait view then everything will be mixed up. Is there a way to dectect this at run time and change the font size to shrink everything and fit it in one page (ie. fit it to page width)?

there is nothing wrong with your answer anthonyc ....I was looking for something simple ie. I just want to have a file print option in File menu and when the user clicks on it ...it will just send the data in dbgrid to printer....I don't know about the report generation...it may make it a little complex ...
oh well thanks anyway...

Sometimes, the answer isn't as simple as you'd like - but that doesn't make it incorrect. Looks to me like dirtdart has offered the most trying to help you. I'd go ahead and award these points to dirtdart.