A Simple VB.NET Freehand Drawing method






4.63/5 (27 votes)
Jul 27, 2003

188359

4510
The code uses a System.Drawing.Drawing2D.GraphicsPath method to follow the users mouse movements. The path is then painted in the control.
Introduction
This is a simple freehand drawing example for VB.NET. I was frustrated at not finding a simple way to draw on a control or a picture in VB.NET. What was a simple task in VB6, seemed to take hundreds of lines of code in .NET sample code. Hopefully this will give other VB.NET programmers ideas on a simple implementation of this type of code.
The code uses a System.Drawing.Drawing2D.GraphicsPath
method to follow the users mouse movements. The path is then painted in the control.
Background
Ideas for this code came from the Microsoft "Scribble" sample code, Christian Graus's excellent article on a C++ code called "Doodle" and the Microsoft website.
Note that this is a VERY pedantic freehand drawing code, so be kind in you comments. :)
History
- Written July, 2003