Printing the content of a ListView
Printing the content of a ListView
Rate Printing the content of a ListView
(1(1 Vote))
Dim i%, LVWidth%, NewTab%, j%
Dim itmX As ListItem
Dim ContaLinha%
LVWidth = 0
For i = 1 To LV.ColumnHeaders.Count
LVWidth = LVWidth + LV.ColumnHeaders(i).Width
Next
NewTab = 0
'imprime o cabeçalho
For i = 1 To LV.ColumnHeaders.Count
NewTab = NewTab + CInt(LV.ColumnHeaders(i).Width * Printer.ScaleWidth / LVWidth)
Printer.Print LV.ColumnHeaders(i).Text;
Printer.CurrentX = NewTab
Next
'imprime uma linha de separação
Printer.Print
imprime_linha
Printer.Print
'se o numero de linhas do ListView for maior que o de linhas a
'a imprimir então imprime o conteúdo total de Listview
If Lines < LV.ListItems.Count And Lines <> 0 Then
ContaLinha = Lines
Else
ContaLinha = LV.ListItems.Count
End If
'imprime os itens e subitens
For i = 1 To ContaLinha
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).Width * Printer.ScaleWidth / LVWidth)
Printer.CurrentX = NewTab
Printer.Print itmX.SubItems(j);
Next
Printer.Print
Next
'envia os dados para impressora
Printer.EndDoc
End Sub
Private Sub imprime_linha()
Dim linha As String
linha = "-"
Printer.CurrentX = 0
While Printer.CurrentX + Printer.TextWidth(linha) <= Printer.ScaleWidth
Printer.Print linha;
Wend
End Sub
Private Sub Form_Click()
call PrintListView(ListView1,4)
End Sub
Printing the content of a ListView Comments
No comments yet — be the first to post one!
Post a Comment