Help creating signature in picturebox

  • Thread starter Thread starter BlueWizzY
  • Start date Start date
B

BlueWizzY

Guest
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class Form1
Private xPoint As Integer
Private yPoint As Integer
Private bDrawing As Boolean = False
Private bm As Bitmap
Private gr As Graphics
Private p As Pen

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

bm = New Bitmap(PictureBox1.Width, PictureBox1.Height)
p = New Drawing.Pen(Color.Black)
gr = Graphics.FromImage(bm)


End Sub

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown


bDrawing = True
xPoint = e.X
yPoint = e.Y


End Sub

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove

If bDrawing Then
gr.DrawLine(p, xPoint, yPoint, e.X, e.Y)
xPoint = e.X
yPoint = e.Y

PictureBox1.Image = bm
End If


End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
bDrawing = False
End Sub

Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseLeave
bDrawing = False
End Sub

End Class

Hi guys, I need some help in creating a signature. I've done the code above. But after i draw a signature on the picturebox and when the mouse leave the picture box, this error "Unable to cast object of type 'System.EventArgs' to type 'System.Windows.Forms.MouseEventArgs'."

How do you fix this error?

Any help is greatly appreciated. Thanks.

Continue reading...
 
Back
Top