|
-
Nov 11th, 2002, 11:10 PM
#1
Thread Starter
Junior Member
Reset PictureBox?
Hello,
I need to reset PictureBox's Image back to blank during some error handling. If the PictureBox was already assigned an Image from a specific file path, but now that path is removed, I need that PictureBox to be reset like when the form it's on first opens.
Code:
Private Sub TextBoxDisplayFront_TabOut(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxDisplayFront.Leave
Try
Dim filepath As String
filepath = TextBoxDisplayFront.Text
Dim img As Image = Image.FromFile(filepath)
PictureBoxBackgroundFront.Image = img
TextBoxDisplayFront.ForeColor = TextBoxDisplayFront.ForeColor.Black
Catch ex1 As System.ArgumentException 'watch for blank textbox
Catch ex2 As System.IO.FileNotFoundException 'watch for invalid path
TextBoxDisplayFront.ForeColor = TextBoxDisplayFront.ForeColor.Red
Catch ex3 As System.OutOfMemoryException 'watch for invalid file format
TextBoxDisplayFront.ForeColor = TextBoxDisplayFront.ForeColor.Red
Finally
Dim filepath As String
filepath = TextBoxDisplayFront.Text
If filepath = "" Then 'if textbox is cleared of path, reset the picturebox
TextBoxDisplayFront.ForeColor = TextBoxDisplayFront.ForeColor.Black
'Code to reset the PictureBox Image
'???
'???
'???
End If
EnableSaveButtons()
TextBoxPhoneFront.Focus()
End Try
End Sub
-
Nov 12th, 2002, 01:02 AM
#2
Frenzied Member
VB Code:
PictureBoxBackgroundFront.Image = nothing
Dont gain the world and lose your soul
-
Nov 12th, 2002, 08:47 AM
#3
Thread Starter
Junior Member
Thanks! I tried everyting except the word "Nothing."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|