Dim img As Image Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If e.Button = Windows.Forms.MouseButtons.Left Then Dim g As Graphics = Graphics.FromImage(PictureBox1.Image) 'Penオブジェクトの作成(幅10の黒色) Dim blackPen As New Pen(Color.Black, 10)
'終点に矢印をつける
'線を描画 g.DrawLine(blackPen, 10, 10, 100, 10)
g.Dispose() 'PictureBoxを再描画する PictureBox1.Invalidate() End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'UnDo処理 Dim g As Graphics = Graphics.FromImage(PictureBox1.Image) g.DrawImage(img, 0, 0)
'PictureBoxを再描画する PictureBox1.Invalidate() End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load img = PictureBox1.Image.Clone