Graphics.DrawString method pops an exception 2nd time I PrintPrevi

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I'm trully excited to use VB.NET's PrintDocument to make my printouts. On
them I draw strings, images and lines.

All perfect, if I invoke the Print or the PrintPreview one time per run.

At second time I onvoke print or preview, the DrawLine or DrawImage go well,
but the first DrawString the program tries to execute pops an exception:

************** Exception Text **************
System.ArgumentException: Invalid parameter used.
at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()


************** Loaded Assemblies **************
mscorlib
(and so on...)

I already checked the content of my DrawString instruction and all the
parameters at the second time have the same values, except the handle number
where objects were new.

Please note that the problem emerges at the second time I try to print or
printpreview, not at the second page of a multiple page printout.

Help please.
 
Update:

I only have this problem if I use the DrawLine method. When I use the
DrawString and the DrawImage, there's no error at the second time I Print or
PrintPreview.

There's something wrong when I mix DrawString and DrawLine that causes
DrawString to fail the second time.
 
Back
Top