Results 1 to 6 of 6

Thread: Printing Document from Listbox

Threaded View

  1. #5

    Thread Starter
    Addicted Member condonethis's Avatar
    Join Date
    Apr 2010
    Location
    TX
    Posts
    133

    Re: Printing Document from Listbox

    Found a solution to the > 1 page issue. I'm using the t variable to remove the first line that was serving as the header, but can't get the VbTab to line up the same.

    Thanks for your help Hack!

    vb Code:
    1. Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    2.         Dim t As Integer = -1
    3.         Dim ListBoxItem As String = String.Empty
    4.         For Each LBItem As String In LstResults.Items
    5.             If t >= 0 Then
    6.                 ListBoxItem = ListBoxItem & vbCrLf & LBItem
    7.             Else
    8.                 t = t + 1
    9.             End If
    10.  
    11.         Next
    12.         Static Lines() As String = ListBoxItem.Split(vbCrLf)
    13.         Static Font As New Font("Arial", 16, FontStyle.Regular, GraphicsUnit.Pixel)
    14.         Static I As Integer
    15.         Dim VerticalPos As Integer = 20
    16.         Do
    17.             e.Graphics.DrawString(Lines(I), Font, Brushes.Black, 20, VerticalPos)
    18.             I += 1
    19.             VerticalPos += Font.Height
    20.             If VerticalPos > e.PageBounds.Bottom Then
    21.                 e.HasMorePages = True
    22.                 Return
    23.             End If
    24.         Loop Until I = Lines.Length
    25.     End Sub
    Last edited by condonethis; Jul 11th, 2011 at 01:16 PM. Reason: Explaining variable that might not be useful to outside coder.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width