VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Printing the content of a ListView

by SERRANA (3 Submissions)
Category: OLE/COM/DCOM/Active-X
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 30th July 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Printing the content of a ListView

Rate Printing the content of a ListView



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

Download this snippet    Add to My Saved Code

Printing the content of a ListView Comments

No comments have been posted about Printing the content of a ListView. Why not be the first to post a comment about Printing the content of a ListView.

Post your comment

Subject:
Message:
0/1000 characters