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




Reply With Quote