yulyos
asked on
How can i print ListView report to the printer.
I writing a program in VB6.
I make a report from ListView:
ListView.View = lvwReport, with 6 columns.
My question is:
How can i print to the printer the report.
thanking you in advance
From:
yulyos@yahoo.com
www.go.to/yulyos
I make a report from ListView:
ListView.View = lvwReport, with 6 columns.
My question is:
How can i print to the printer the report.
thanking you in advance
From:
yulyos@yahoo.com
www.go.to/yulyos
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This subroutine prints the contents of a ListView control in report view. The parameter Lines specifies the number of rows that will be printed, beginning with the first row. If LV.ListCount is less than the parameter Lines, then all the rows will be printed. The columns in the LV control are tabbed to be uniformly distributed across the page.
Public Sub PrintListView(LV As ListView, Lines%)
Dim i%, LVWidth%, NewTab%, j%
Dim itmX As ListItem
Dim LineCount%
LVWidth = 0
For i = 1 To LV.ColumnHeaders.Count
LVWidth = LVWidth + LV.ColumnHeaders(i).Width
Next
NewTab = 0
For i = 1 To LV.ColumnHeaders.Count
NewTab = NewTab + CInt(LV.ColumnHeaders(i).W idth * Printer.ScaleWidth / LVWidth)
Printer.Print LV.ColumnHeaders(i).Text;
Printer.CurrentX = NewTab
Next
Printer.Print
If Lines < LV.ListItems.Count And Lines <> 0 Then
LineCount = Lines
Else
LineCount = LV.ListItems.Count
End If
For i = 1 To LineCount
NewTab = 0
Set itmX = LV.ListItems(i)
Printer.Print itmX.Text;
For j = 1 To LV.ColumnHeaders.Count - 1
NewTab = NewTab + CInt(LV.ColumnHeaders(j).W idth * Printer.ScaleWidth / LVWidth)
Printer.CurrentX = NewTab
Printer.Print itmX.SubItems(j);
Next
Printer.Print
Next
End Sub
Public Sub PrintListView(LV As ListView, Lines%)
Dim i%, LVWidth%, NewTab%, j%
Dim itmX As ListItem
Dim LineCount%
LVWidth = 0
For i = 1 To LV.ColumnHeaders.Count
LVWidth = LVWidth + LV.ColumnHeaders(i).Width
Next
NewTab = 0
For i = 1 To LV.ColumnHeaders.Count
NewTab = NewTab + CInt(LV.ColumnHeaders(i).W
Printer.Print LV.ColumnHeaders(i).Text;
Printer.CurrentX = NewTab
Next
Printer.Print
If Lines < LV.ListItems.Count And Lines <> 0 Then
LineCount = Lines
Else
LineCount = LV.ListItems.Count
End If
For i = 1 To LineCount
NewTab = 0
Set itmX = LV.ListItems(i)
Printer.Print itmX.Text;
For j = 1 To LV.ColumnHeaders.Count - 1
NewTab = NewTab + CInt(LV.ColumnHeaders(j).W
Printer.CurrentX = NewTab
Printer.Print itmX.SubItems(j);
Next
Printer.Print
Next
End Sub
http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=50