1
我想知道如果有一個辦法解決寫作有沒有辦法用一個類來分別處理多個事件?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
一遍又一遍。
這是我的嘗試:
Public Class Ship
Public Property name As String
Public Property image As PictureBox
Public Property length As Integer
Public Property direction As String
Public Property selected As Boolean
Public Property placed As Boolean
Public Property location As Array
Public Sub New(ByVal namep As String, ByVal imagep As PictureBox, ByVal lengthp As Integer, ByVal directionp As String, ByVal selectedp As Boolean, ByVal placedp As Boolean, ByVal locationp As Array)
name = namep
image = imagep
length = lengthp
direction = directionp
selected = selectedp
placed = placedp
location = locationp
End Sub
Private Sub Ship_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.image.MouseMove
'Events here
End Sub
End Class
,但我得到的錯誤:事件「形象」不能被發現和聲明的最終預期
雖然有效,但它會在其他圖片框,文本框,按鈕和標籤上留下圖像的副本。同樣,當你太多地移動圖像時,它會創建3個副本,同樣也會留下副本。 (當你放手時,它們全部消失) – alexanderd5398
沒關係,我修好了。 :) 謝謝你的幫助。 – alexanderd5398
如果您可以共享修補程序,它可能會幫助其他人 – Mych