RATE THIS ANSWER
0
Click to Vote:
0
0
hi,
1. you can get the number of rows from the recordset you use to fill the datagrid. if you use ado it would be something like recordset.RecordCount. usually you can gain access to the recordset through the datagrid's DataSource property.
2. to print the datagrid you can try the following code. however it's only print the currently visible rows in the datagrid. to print all rows it's more efficient if you print from the recordset directly. it was formatted to print each row in separate line, however if you want to align the columns properly you must calculate the maximum width of each column and insert additional vbTab(s) as appropriate.
'Print column headers
For CCol = 0 To DataGrid1.Columns.Count - 1
Printer.Print DataGrid1.Columns(CCol).Caption & vbTab
Next
Printer.Print vbCrLf
'Print visible rows
For RRow = 0 To DataGrid1.VisibleRows - 1
For CCol = 0 To DataGrid1.Columns.Count - 1
Printer.Print DataGrid1.Columns(CCol).CellText _
(DataGrid1.RowBookmark(RRow)) & vbTab
Next
Printer.Print vbCrLf
Next
hope this will help
Last Answered:
Sep 16 2006 0:34 AM GMT by Julius 
0 pts.