G
Guest
I'm developing an application for my customer to log info about photos/images
he has done. Each record contains the file name of the image and displays
the image based on that file name in a PictureBox control.
The app works well until trying to go to another record from a record where
there is not a file name present. If no file name, a label displays that an
image is needed. But if you try to go to another record with an image, that
records' image does not display.
I use the Dispose method if the current record does not have an image or
else the previous record's image will display. But it appears that the
Dispose method keeps the image from displaying for any record that you go to
next.
I tried setting the PictureBox to Nothing, instead of using Dispose, but
that gave me a Null error when trying to store an image to it.
Here is a snippet of my code:
If Me.txtImageFileName IsNot DBNull.Value And
Me.txtImageFileName.Text <> "" Then
Me.lblImageNeeded.Visible = False
Me.PhotoOrImage.Image =
Image.FromFile(Me.txtImageFileName.Text)
Else
Me.PhotoOrImage.Dispose()
Me.lblImageNeeded.Visible = True
End If
Is there some other method to use other than Dispose?
Thanks in advance.
he has done. Each record contains the file name of the image and displays
the image based on that file name in a PictureBox control.
The app works well until trying to go to another record from a record where
there is not a file name present. If no file name, a label displays that an
image is needed. But if you try to go to another record with an image, that
records' image does not display.
I use the Dispose method if the current record does not have an image or
else the previous record's image will display. But it appears that the
Dispose method keeps the image from displaying for any record that you go to
next.
I tried setting the PictureBox to Nothing, instead of using Dispose, but
that gave me a Null error when trying to store an image to it.
Here is a snippet of my code:
If Me.txtImageFileName IsNot DBNull.Value And
Me.txtImageFileName.Text <> "" Then
Me.lblImageNeeded.Visible = False
Me.PhotoOrImage.Image =
Image.FromFile(Me.txtImageFileName.Text)
Else
Me.PhotoOrImage.Dispose()
Me.lblImageNeeded.Visible = True
End If
Is there some other method to use other than Dispose?
Thanks in advance.