|
-
Jul 17th, 2012, 05:32 PM
#1
Thread Starter
New Member
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
-
Jul 17th, 2012, 05:48 PM
#2
Frenzied Member
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.
-
Jul 18th, 2012, 12:56 AM
#3
Re: PictureBox image not displaying in PrintForm
 Originally Posted by elispop122003
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
Last edited by boops boops; Jul 18th, 2012 at 01:06 AM.
-
Jul 18th, 2012, 07:43 AM
#4
Thread Starter
New Member
Re: PictureBox image not displaying in PrintForm
 Originally Posted by mebhas
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|