Kiki0602
Kiki0602
2017-07-13 01:37
采纳率: 100%
浏览 1.2k

VB. net 怎样让panel做的画图板缩小化再打开后画的图还在?

VB. net 怎样让panel做的画图板缩小化再打开后画的图还在?
下面是我的代码,请问要怎么修改才可以呢?
谢谢大家了!

 Public Class Form1
    Dim mygraphics As Graphics
    Dim Mypen As Pen
    Dim Draw As Boolean = False
    Dim Start As Point


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        mygraphics = Me.pnlPaint.CreateGraphics
        Mypen = New Pen(Color.Black,10)
        pnlPaint.BackColor=Color.Black


    End Sub


    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        mygraphics.Dispose()
        Mypen.Dispose()

    End Sub

    Private Sub btnColor1_Click(sender As Object, e As EventArgs) Handles btnColor1.Click
        Mypen.Color = Color.White
    End Sub

   Private Sub pnlPaint_MouseMove(sender As Object, e As MouseEventArgs) Handles pnlPaint.MouseMove

        If e.Button And MouseButtons.Left Then
            pnlPaint.CreateGraphics.DrawLine(Mypen, Start.X, Start.Y, e.X, e.Y)


        End If
        Start = e.Location

    End Sub

    Private Sub pnlPaint_MouseUp(sender As Object, e As MouseEventArgs) Handles pnlPaint.MouseUp
        Draw = False

    End Sub

    Private Sub pnlPaint_MouseDown(sender As Object, e As MouseEventArgs) Handles pnlPaint.MouseDown
        Draw = True

    End Sub




End Class
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐