All datagrid’s data print
0 pts.
0
Q:
All datagrid's data print
hi,
when i find out the following code i implement it on my project and its working fine. that was very good. now i have 2 Questions.
Dim RRow As Integer, CCol As Integer

Printer.Print ""
DataGrid1.Row = 0
DataGrid1.Col = CCol
For CCol = 0 To DataGrid1.Columns.Count - 1
DataGrid1.Col = CCol
Debug.Print DataGrid1.Text
Next
CCol = 0
DataGrid1.Col = CCol
For RRow = 1 To 6
DataGrid1.Row = RRow
For CCol = 0 To DataGrid1.Columns.Count - 1
DataGrid1.Col = CCol
Printer.Print DataGrid1.Text
Next
Next
Printer.EndDoc





1st:- i retreive data in datagrid from database according to my requirment.i.e if there are 3 Records it would be print 3. in print code i have loop for columns count but not for Rows.

2:- the print result on a paper in a single line not as shown in DataGrid. i want the print result on paper as shown in DataGird. All Columns Heading then All Rows as shown in DataGrid.

Please help me in this regards.
Thanks.
ASKED: Sep 1 2006  6:40 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
0 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

qasimkhans   0 pts.  |   Sep 18 2006  8:31AM GMT

thankx for your reply. i used this code but its not working. nothing happend. plz instructe me with other code.
thankx

 
0