Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I am now unable to edit my prior post so here is an update.

 

Here is a simpler version of code that I would like to have print 1 line on a new page for ten pages.

 

Unfortunately all I get is the text overwriting all on the first page.

 

Option Explicit On 

Public Class Form1
   Inherits System.Windows.Forms.Form

   Private Sub btnPrint_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles _
btnPrint.Click
       PrintPreviewDialog1.ShowDialog()
   End Sub

   Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles PrintDocument1.PrintPage
       Dim i As Integer

       For i = 0 To 10
           e.Graphics.DrawString("Line of Credit Chronology" & i, _
           New Font("Microsoft Sans Serif", 14, FontStyle.Bold), _
Brushes.Black, 50, 75 )
           If i < 10 Then
               e.HasMorePages = True
           Else
               e.HasMorePages = False
           End If
       Next i

   End Sub

End Class

 

Can anyone tell me what I am doing wrong or right?

 

How do I get a clean blank page to print new data?

Edited by ahayes1ic
  • *Gurus*
Posted
You don't want to have a loop there, for a start. You'll have to keep a form-scoped variable around saying which number to print. Like you're doing now you'll write the text, then if i < 10 then tell it it has more pages. You'll have to manually increment it each time too.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...