Alright, the title is a bit misleading.
So I have a program that allows the user to load up some images, which appear in a ListBox. You can click the imported images and they load into a PictureBox.
Here's the code:
vb.net Code:
Public Class Form1 Private Sub import_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles import.Click Dim result As DialogResult = openfile.ShowDialog Images.Items.Add(openfile.FileName) Images.SelectedIndex = 0 PictureBox1.Image = Image.FromFile(Images.Text) End Sub Private Sub Images_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Images.SelectedIndexChanged PictureBox1.Image = Image.FromFile(Images.Text) End Sub Private Sub delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delete.Click Images.Items.Remove(Images.SelectedItem) End Sub End Class
Now here is my problem: when the user tries to delete a image, an exception occurs like this:
You can load up the code and see for yourself. Now I need to be able to delete these images from the ListBox. The exception occurs because the image is now null, and can't load.Code:System.ArgumentException was unhandled The path is not of a legal form.
Any ideas?




Reply With Quote