本文介绍了使用大量的记忆资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码有什么问题?它似乎使用了大量的内存资源。因为当它第二次运行时,打开文件对话框无法正常工作。请提前帮助我。谢谢。

what's problem whit this code? it seem's uses much memory resource. because when it runs for second time , the open file dialog does not work properly.please help me.thanks in advance.

 Try

    If OpenFD.ShowDialog = Windows.Forms.DialogResult.OK Then
        PictureBox3.Image = Image.FromFile(OpenFD.FileName)

        Dim NewSize As New Size(800, 600)
        ResizedImage = New Bitmap(PictureBox3.Image, NewSize)
        PictureBox3.Image = ResizedImage
        PictureBox3.BackgroundImageLayout = ImageLayout.Stretch
    End If

    If PictureBox3.Image Is Nothing Then
        Exit Sub
    End If

    Dim i As Integer = Me.Panel2.Controls.Count - 1
    Dim x1 As Integer
    Dim y1 As Integer
    If i = -1 Then
        x1 = Panel2.Location.X + 10
        y1 = Panel2.Location.Y + 10
    Else
        x1 = Panel2.Controls(i).Location.X + 110
        y1 = Panel2.Controls(i).Location.Y
    End If

    If x1 < Panel2.Width - 50 Then
        x1 = Panel2.Location.X + 10
        y1 = Panel2.Controls(i).Location.Y + 110
    End If
    Dim ctlLocation As New Point(x1, y1)
    Dim ctrl As New PictureBox
    ctrl.Image = PictureBox3.Image
    ctrl.Location = ctlLocation
    ctrl.Size = New Size(100, 100)
    ctrl.SizeMode = PictureBoxSizeMode.StretchImage
    ctrl.BorderStyle = BorderStyle.FixedSingle
    Me.Panel2.Controls.Add(ctrl)
    PictureBox3.Image = Nothing

    AddHandler ctrl.Click, AddressOf ClickHandler1
Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "بروز خطا،لطفا دوباه سعی کنید")
End Try

推荐答案


这篇关于使用大量的记忆资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 23:46