Click here to Skip to main content
15,900,724 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Error sending mail using smtp Pin
amaneet11-Apr-07 21:00
amaneet11-Apr-07 21:00 
AnswerRe: Error sending mail using smtp Pin
Dave Kreskowiak12-Apr-07 3:45
mveDave Kreskowiak12-Apr-07 3:45 
AnswerRe: Error sending mail using smtp Pin
A*****12-Apr-07 11:42
A*****12-Apr-07 11:42 
QuestionRather Frustrating Issue Pin
Diagathon11-Apr-07 7:38
Diagathon11-Apr-07 7:38 
AnswerRe: Rather Frustrating Issue Pin
Dave Kreskowiak11-Apr-07 7:44
mveDave Kreskowiak11-Apr-07 7:44 
AnswerRe: Rather Frustrating Issue Pin
Code_Doctor16-Apr-07 17:00
Code_Doctor16-Apr-07 17:00 
QuestionPrinting problem Pin
xjamiex9011-Apr-07 4:14
xjamiex9011-Apr-07 4:14 
AnswerRe: Printing problem Pin
Dave Kreskowiak11-Apr-07 6:26
mveDave Kreskowiak11-Apr-07 6:26 
From what I can see, or more accurately what I can NOT see, in you're code is any support for getting the page number that is currently being printed and using that in some way as an index into what you're supposed to be printing.

What your GraphicPrint1 handler is called, it's job is to print the single page that is being worked on. Nowhere in your code are you tracking what is on the current page, what you have printed, or what you have remaining to be printed.

In the example that I'm assuming you used to model this code from, in the PrintDocument.PrintPage event documentation on MSDN, notice that the StreamReader at the top of the code (declared in class scope) is what is tracking what was printed and what remains to be printed:
Public Class PrintingExample
    Inherits System.Windows.Forms.Form
 
    Private streamToPrint As StreamReader
 
    ...    
 
    Private Sub printButton_Click(sender As Object, e As EventArgs)
        Try
            streamToPrint = New StreamReader("C:\My Documents\MyFile.txt")
 
        ...
 
        Finally
            streamToPrint.Close()
        End Try
    End Sub
 
    Private Sub pd_PrintPage(sender As Object, ex As PrintPageEventArgs)
        Dim line As String = Nothing

        ...
 
        line = streamToPrint.ReadLine()
 
        ...
 
        If Not (line Is Nothing) Then
            ev.HasMorePages = True
        Else
            ev.HasMorePages = False
        End If
    End Sub

OK. So how does the PrintPage handler know when there is no more text to print? The streamToPrint is defined in class scope, so it doesn't lose it's place inside the PrintPage handler when everything else in there goes out of scope and is destroyed. That StreamReader is what is keeping track of what has been printed and what still needs to be printed. Notice that the StreamReader is created and destroyed in the Button_Click event, not in the PrintPage event!

Your code has to do something similar. It has to have class scoped variable that keep track of what has been printed or what still needs to be printed, like an index number into an array or collection that your GraphicPrint event has to advance to the next image and check to see if it still has more images to go.


Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Printing problem Pin
xjamiex9011-Apr-07 6:30
xjamiex9011-Apr-07 6:30 
GeneralRe: Printing problem Pin
Dave Kreskowiak11-Apr-07 7:12
mveDave Kreskowiak11-Apr-07 7:12 
QuestionSudden form creation error after no code change Pin
lucjon11-Apr-07 3:17
lucjon11-Apr-07 3:17 
GeneralEdit Pin
lucjon11-Apr-07 3:29
lucjon11-Apr-07 3:29 
GeneralRe: Edit Pin
Dave Kreskowiak11-Apr-07 5:20
mveDave Kreskowiak11-Apr-07 5:20 
AnswerRe: Edit Pin
lucjon12-Apr-07 20:25
lucjon12-Apr-07 20:25 
QuestionAccess Database from Website In vb.net [modified] Pin
Kiran S. S.11-Apr-07 2:48
Kiran S. S.11-Apr-07 2:48 
AnswerRe: Access Database from Website In vb.net Pin
Dave Kreskowiak11-Apr-07 5:18
mveDave Kreskowiak11-Apr-07 5:18 
GeneralRe: Access Database from Website In vb.net Pin
Kiran S. S.11-Apr-07 18:13
Kiran S. S.11-Apr-07 18:13 
GeneralRe: Access Database from Website In vb.net Pin
Dave Kreskowiak12-Apr-07 3:42
mveDave Kreskowiak12-Apr-07 3:42 
GeneralRe: Access Database from Website In vb.net Pin
Kiran S. S.12-Apr-07 18:14
Kiran S. S.12-Apr-07 18:14 
Questionapi problem. Pin
amaneet11-Apr-07 2:34
amaneet11-Apr-07 2:34 
AnswerRe: api problem. Pin
Dave Kreskowiak11-Apr-07 5:14
mveDave Kreskowiak11-Apr-07 5:14 
QuestionHow to copy file from FTP folder Pin
virendra_00711-Apr-07 2:19
virendra_00711-Apr-07 2:19 
AnswerRe: How to copy file from FTP folder Pin
Dave Kreskowiak11-Apr-07 5:06
mveDave Kreskowiak11-Apr-07 5:06 
GeneralRe: How to copy file from FTP folder Pin
virendra_00711-Apr-07 23:36
virendra_00711-Apr-07 23:36 
GeneralRe: How to copy file from FTP folder Pin
Dave Kreskowiak12-Apr-07 3:40
mveDave Kreskowiak12-Apr-07 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.