有人能幫我嗎?我試圖繪製圖像,我得到這個錯誤:爲什麼我在System.Drawing.dll中得到System.ArgumentException
An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll"
有以下功能:被點擊的按鈕之前
Dim x, y, xlatime, ylungime As Integer
Dim myImage As Image
Dim folder As String
Sub PictureBox1_Paint(sender1 As Object, er As PaintEventArgs)
Dim r As New Rectangle(x, y, xlatime, ylungime)
er.Graphics.DrawImage(myImage, r)
End Sub
Private Function deseneaza(ByVal poza As String, ByRef x_perm As Integer, ByRef y_perm As Integer, ByRef lungime As Integer, ByRef latime As Integer)
myImage = Image.FromFile(poza)
x = x_perm
y = y_perm
xlatime = latime
ylungime = lungime
Refresh()
Return Nothing
End Function
Private Sub joaca_buton_Click(sender As Object, e As EventArgs) Handles joaca_buton.Click
Timer1.Stop()
nor.Hide()
nor_mic.Hide()
logo.Hide()
exit_buton.Hide()
joaca_buton.Hide()
continua_buton.Hide()
optiuni_buton.Hide()
BackgroundImage.Dispose()
deseneaza(folder + "\incarcare1.png", 0, 0, 729, 1008)
End Sub
您確定圖片加載?你調試了你的工作嗎? – OneFineDay
除非您告訴它您正在控制該事件,否則繪製事件會多次觸發 - 而且我看不到任何代碼。所以當你打開表單時,繪畫事件正在發射。 – OneFineDay
如果你的函數沒有返回任何東西,它應該是一個子類。請發佈更完整的代碼,包括聲明。 –