vb.net的picturebox画直线的函数是哪个?vb6.0是picture1.line就可以,但是vb.net没有啊
1个回答
展开全部
Dim PtStart As Point '记录绘制直线的起始点
Dim PtEnd As Point '记录绘制直线的终点
Dim ShouldDrawLine As Boolean '是否绘制直线
'记录鼠标左键点击的位置,第二次点击后开始绘制直线
Private Sub Pic1_MouseDown()Sub Pic1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Pic1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
If Not ShouldDrawLine Then
PtStart = New Point(e.X, e.Y)
ShouldDrawLine = True
Else
PtEnd = New Point(e.X, e.Y)
'下面两句根据需要进行取舍
'Call DrawLine(PtStart, PtEnd) '绘制一条直线
Call DrawLines(PtStart, PtEnd) '绘制多条直线
ShouldDrawLine = False
End If
End If
End Sub
'绘制鼠标两次点击位置之间的直线
Private Sub DrawLine()Sub DrawLine(ByVal mPoint1 As Point, ByVal mPoint2 As Point)
Pic1.Refresh() '用于刷新Picturebox表面
Pic1.CreateGraphics.DrawLine(Pens.Blue, mPoint1, mPoint2) '绘制两点间的直线
End Sub
'绘制多条直线,每两次鼠标点击确定一条线
Private Sub DrawLines()Sub DrawLines(ByVal mPoint1 As Point, ByVal mPoint2 As Point)
'此句不可删除,用于清除鼠标点击前的轨迹
ControlPaint.DrawReversibleLine(Pic1.PointToScreen(mPoint1), Pic1.PointToScreen(mPoint2), Color.Red)
Pic1.CreateGraphics.DrawLine(Pens.Blue, mPoint1, mPoint2) '绘制两点间的直线
End Sub
Dim PtEnd As Point '记录绘制直线的终点
Dim ShouldDrawLine As Boolean '是否绘制直线
'记录鼠标左键点击的位置,第二次点击后开始绘制直线
Private Sub Pic1_MouseDown()Sub Pic1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Pic1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
If Not ShouldDrawLine Then
PtStart = New Point(e.X, e.Y)
ShouldDrawLine = True
Else
PtEnd = New Point(e.X, e.Y)
'下面两句根据需要进行取舍
'Call DrawLine(PtStart, PtEnd) '绘制一条直线
Call DrawLines(PtStart, PtEnd) '绘制多条直线
ShouldDrawLine = False
End If
End If
End Sub
'绘制鼠标两次点击位置之间的直线
Private Sub DrawLine()Sub DrawLine(ByVal mPoint1 As Point, ByVal mPoint2 As Point)
Pic1.Refresh() '用于刷新Picturebox表面
Pic1.CreateGraphics.DrawLine(Pens.Blue, mPoint1, mPoint2) '绘制两点间的直线
End Sub
'绘制多条直线,每两次鼠标点击确定一条线
Private Sub DrawLines()Sub DrawLines(ByVal mPoint1 As Point, ByVal mPoint2 As Point)
'此句不可删除,用于清除鼠标点击前的轨迹
ControlPaint.DrawReversibleLine(Pic1.PointToScreen(mPoint1), Pic1.PointToScreen(mPoint2), Color.Red)
Pic1.CreateGraphics.DrawLine(Pens.Blue, mPoint1, mPoint2) '绘制两点间的直线
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询