私は次のコードを書きましたが、私が理解しようとしていない問題があります..マウスをクリックすると、画像ボックスの画像に単純な線を引こうとしています。ただし、ペイントメソッドが呼び出されますが、描画されません。代わりに、画像ボックスで画像をスクロールすると、その時点の線が描画されます.. Pls help
Private Sub picCurrentimage_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picCurrentimage.MouseDown
px = e.X
py = e.Y
highlightPic(px, py)
End Sub
Private Sub highlightPic(ByVal x1 As Integer, ByVal y1 As Integer)
haspoint = True
picCurrentimage.Invalidate()
picCurrentimage.Update()
End Sub
Private Sub picCurrentimage_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picCurrentimage.Paint
If haspoint Then
Dim g As Graphics = picCurrentimage.CreateGraphics
Dim r As Rectangle = New Rectangle(px, py, 600, 10)
Dim pen As Pen = New Pen(Color.FromArgb(128, 32, 100, 200), 1)
Dim b As Brush = New SolidBrush(pen.Color)
g.FillRectangle(b, r)
End If
End Sub