我被卡住了,不知道该怎么办,我正在尝试制作一个image viewer
,并将image
by 文件夹的所有路径放在 a 中listbox
,然后当我尝试在列表中选择时index 2
,我收到错误并显示“OutOfMemoryException”
这是我的代码
Public Class Form1
Dim myimg As Array
Private Sub img_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles img.Click
If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
myimg = IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath)
ListBox1.Items.AddRange(myimg)
ListBox1.SelectedIndex = 0
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Refresh()
Me.BackgroundImage = Nothing
Me.BackgroundImage = Image.FromFile(ListBox1.SelectedItem.ToString)
End Sub
Private Sub min_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles min.Click
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub max_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles max.Click
Me.WindowState = FormWindowState.Normal
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
错误位于此处
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Refresh()
Me.BackgroundImage = Nothing
Me.BackgroundImage = Image.FromFile(ListBox1.SelectedItem.ToString)
End Sub
,请帮忙谢谢:)