I am using VS2015, I have a small form with a picturebox. I can't close the form until I choose an image for the picturebox. How can I close the form without choosing an image? It seems to hang.
This Line in Form1.Closed seems to cause the problem. When I remove it everything is fine except then the image won't save when I go to reload the program.
My.Settings.SetCharImage = System.IO.Path.GetFullPath(OpenImage.FileName)
Imports System.ComponentModel
Public Class Form1
Dim OpenImage As New OpenFileDialog
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles CharImage1.Click
OpenImage.Filter = "*.JPG;*.PNG;*.GIF|*.jpg;*.png;*.gif"
If OpenImage.ShowDialog = DialogResult.OK Then
CharImage1.Image = Image.FromFile(OpenImage.FileName)
End If
End Sub
Private Sub DisplayURL_Click(sender As Object, e As EventArgs) Handles DisplayURL.Click
End Sub
Private Sub Form1_Closed(sender As Object, e As EventArgs) Handles Me.Closed
My.Settings.SetCharImage = System.IO.Path.GetFullPath(OpenImage.FileName)
My.Settings.Save()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
TextBox1.Text = My.Settings.SetCharImage
CharImage1.ImageLocation = My.Settings.SetCharImage
End Sub
End Class