Trying to print the complete list of items from a listbox using this code. When I set 'e.HasMorePages' to True, it will continue to run on forever. Not sure what I am missing here, but the way this is now only gives me a single page of items. Thanks for any assistance on this.
Code:Private Sub BtnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrint.Click PrintDocument1.Print() End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim fnt As New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Point) Dim ListBoxItem As String = String.Empty For Each LBItem As String In ListBox2.Items ListBoxItem = ListBoxItem & vbCrLf & LBItem Next ListBoxItem = ListBoxItem.Substring(vbCrLf.Length) e.Graphics.DrawString(ListBoxItem, fnt, Brushes.Black, 0, 0) e.HasMorePages = False End Sub




Reply With Quote
