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.

Answer Wiki

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.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your response...

Discuss This Question: 1 &nbspReply

There was an error processing your information. Please try again later.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your reply...

Ask a Question

Free Guide: Managing storage for virtual environments

Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!

To follow this tag...

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy