任何幫助,將不勝感激。如何在用戶點擊鼠標的面板上創建彩色圓點?我可以獲取鼠標點擊的座標並通過消息框輸出,但我無法在用戶點擊的面板上繪製點。我有這些代碼嘗試。在點擊事件中畫一個點
Private Sub createDot(x, y)
MsgBox(x & " " & y)
Dim myGraphics As Graphics = Me.CreateGraphics
Dim myPen As Pen
myPen = New Pen(Drawing.Color.Maroon, 20)
myGraphics.DrawRectangle(myPen, x, y, 1, 1)
End Sub
Private Sub Panel1_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseClick
missed += 1
lblMissed.Text = missed
Dim x, y As Integer
x = e.X.ToString
y = e.Y.ToString
createDot(x, y)
End Sub
謝謝!
什麼是ToString? x,y必須是整數而不是字符串!你應該在'MsgBox','MsgBox(x.ToString()&「)&y.ToString())' –