-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: shashijeevan
Message 1 in Discussion

Hi,   I have used the following approach to cancel printing if the the information to 
be printed is missing. But it doesn't seems to be working. Is there any problem with 
the current approach?  
private void printPage(object sender, PrintPageEventArgs ev) 
{
   ev.Graphics.DrawString("This is a photograph", printFont, Brushes.BurlyWood, new 
PointF(0,0));
   try
   {
      ev.Graphics.DrawImage(Image.FromFile("photo3.jpg"), 0, 0, new Rectangle(0,0, 
315, 338), GraphicsUnit.Pixel);
   }
   catch(FileNotFoundException exp)
   {
      ev.Cancel=true;
      return;
   }
 
   int height = printFont.Height;
   ev.Graphics.DrawImage(Image.FromFile("photo.jpg"), 0, height, new Rectangle(0, 0, 
315, 338), GraphicsUnit.Pixel);
   ev.HasMorePages = false ;
}There is only on file (photo.jpg) present. So when this code tries to print 
photo3.jpg it gets FileNotFoundException and I set the Cancel property to true and 
return.I expected this to cancel the printing job altogether but it printed the 
content that was drawn before I got the exception.Is this is a bug in .Net?How do I 
cancel this job altogether?Any pointer will be really helpful.regards,shashi

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to