Results 1 to 3 of 3

Thread: Reset PictureBox?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    20

    Question 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

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    VB Code:
    1. PictureBoxBackgroundFront.Image = nothing
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    20
    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
  •  



Click Here to Expand Forum to Full Width