Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Showing an image in PictureBox
Message
De
23/11/2009 21:03:34
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Showing an image in PictureBox
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01436254
Message ID:
01436254
Vues:
108
I have a VS2008 Winform. I am trying to display an image in a PictureBox at runtime. I use the below code to display the selected image. This works and the image is displayed on the form, however, the PictureBox object keeps the file opened. So if I try to rename or delete the file from Windows explorer, Windows tells me that the files is in use.

If I call the below code multiple times and pass in a different image name each time, the PictureBox control keeps a file handle open for each image file until I close my form.

How do I release any file handle before displaying the next image in the PictureBox? Or, is there a better way to display an image in a Winform?
System.Drawing.Bitmap o = new Bitmap(myImage);
myPictureBox.Image = o;
Thanks,

Jerry
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform