1

立ち往生していて、何をすべきかわかりません。 を作成しようとしていて、 by フォルダーimage viewerのすべてのパスを に配置し、 のリストで選択しようとすると、エラーが発生し、「OutOfMemoryException」と表示されましたimagelistboxindex 2

ここに私のコードがあります

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

、助けてくださいありがとう:)

4

2 に答える 2