Results 1 to 4 of 4

Thread: PictureBox image not displaying in PrintForm

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Location
    Terre Haute, IN
    Posts
    5

    Angry PictureBox image not displaying in PrintForm

    I have am wanting to populate my form fields on form load. One of these fields is a picturebox. I am passing the imagelocation to the pb on load. At the end of the load event I am calling my printForm() which prints the form. For some reason, the image only shows up in the print preview if I run the printForm() on a button click instead of at the end of the load. I have tried to run it on form_shown and form_closing. It fails to display. Any ideas on what I am doing wrong?

    Code:
        Public Sub printForm()
            With Me.PrintForm1
                .PrinterSettings.DefaultPageSettings.Margins.Left = 0.05
                .PrinterSettings.DefaultPageSettings.Margins.Top = 0.05
                .PrintAction = PrintAction.PrintToPreview
                .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)
            End With
            Me.Close()
        End Sub
    
        Private Sub frmReceipt_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            gInvId = "12345"
            gTTime = "12:45:56"
            gTDate = "07/17/2012"
            gCustId = "602010"
            gCSubId = "000"
            gCust = "Customer"
            gAcctId = "*1234"
            gTotal = "$27.56"
            gImgLoc = "C:\SigImages\test1.bmp"
            Timer1.Enabled = False
    
            lblInvNo.Text = gInvId
            lblTrnTim.Text = gTTime
            lblTrnDat.Text = gTDate
            lblTrnCu.Text = gCustId & gCSubId
            lblTrnCus.Text = gCust
            lblAcctNo.Text = gAcctId
            lblInvAmt.Text = gTotal
            pbSig.ImageLocation = gImgLoc
            printForm()
        End Sub

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: PictureBox image not displaying in PrintForm

    i would be worthwhile to have a look at the form and see if the form looks like what you want it to. also try to send it to printer on the picturebox's loadcomplete event, just a thought.

  3. #3
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: PictureBox image not displaying in PrintForm

    Quote Originally Posted by elispop122003 View Post
    I have am wanting to populate my form fields on form load. One of these fields is a picturebox. I am passing the imagelocation to the pb on load. At the end of the load event I am calling my printForm() which prints the form. For some reason, the image only shows up in the print preview if I run the printForm() on a button click instead of at the end of the load. I have tried to run it on form_shown and form_closing. It fails to display. Any ideas on what I am doing wrong?
    The form layout is not completed until after the Load event, so you are not waiting for the image to be loaded. I agree with mebhas, call printForm from the picture box LoadCompleted event.
    BB

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Location
    Terre Haute, IN
    Posts
    5

    Re: PictureBox image not displaying in PrintForm

    Quote Originally Posted by mebhas View Post
    i would be worthwhile to have a look at the form and see if the form looks like what you want it to. also try to send it to printer on the picturebox's loadcomplete event, just a thought.
    This was exactly what I was looking for. Thanks!

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