。。我这有
这是 visual studio 2010
Public Class Form1
Inherits System.Windows.Forms.Form
Private mygraphic As Graphics '定义画布
Private mypen As New Pen(Color.Blue, 4) '定义画笔
Private x, y As Integer '记录坐标点的(x,y) 坐标点
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.BackColor = Color.White '定义 背景色 为白色
mygraphic = PictureBox1.CreateGraphics
x = 0
y = 0
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
x = e.X
y = e.Y
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button = MouseButtons.Left Then '如果左键按下
mygraphic.DrawLine(mypen, x, y, e.X, e.Y) ' 会直线条
x = e.X '将下一条线的起始设置为上一条线的终点
y = e.Y
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mygraphic.Clear(Color.White)
End Sub
End Class