Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PictureBox Not Releasing Image Files

Posted on 2004-10-22
6
Medium Priority
?
214 Views
Last Modified: 2010-04-23
I am using a PictureBox on an employee information form to display a JPG picture. The form has a combo box on it to switch employees. When I change to the next employee, the previous picture file is not being release. If I try to do anything with it, it says it is in use. Usually after a while it will release on its own. Is there any way to make it release faster?
0
Comment
Question by:m9s999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:bramsquad
ID: 12383390
Me.PictureBox1.Refresh()

~b
0
 

Author Comment

by:m9s999
ID: 12383721
Refresh didn't help.

The picturebox is displaying the new picture right away. It is just keeping the previous files open for a while.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12384649
How are you creating an image from the file and displaying it in the PictureBox?

~IM
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:m9s999
ID: 12388515
I don't have the code in front of me right now, but I think the syntax i'm using is:
PictureBox1.Image = Image.FromFile("PathToPicture")
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 12389502
You can use code like this to prevent a file lock on the image:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = DialogResult.OK Then
            Dim tempImg As Image = Image.FromFile(OpenFileDialog1.FileName)
            PictureBox1.Image = New Bitmap(tempImg)
            tempImg.Dispose()
        End If
    End Sub

~IM
0
 

Author Comment

by:m9s999
ID: 12424232
This works. Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question