Click here to Skip to main content
12,701,314 members (36,321 online)
Click here to Skip to main content
Add your own
alternative version


31 bookmarked

A Simple VB.NET Freehand Drawing method

, 26 Jul 2003
Rate this:
Please Sign up or sign in to vote.
The code uses a System.Drawing.Drawing2D.GraphicsPath method to follow the users mouse movements. The path is then painted in the control.

Sample Image - Freehand_Drawing.jpg


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.


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. :)


  • Written July, 2003


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

John Buettner
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

BugUnwanted Line !? Pin
Member 1103453921-Nov-15 22:47
memberMember 1103453921-Nov-15 22:47 
QuestionVery Nice and Simple Pin
Member 40329031-Dec-13 9:38
memberMember 40329031-Dec-13 9:38 
GeneralVery Nice Pin
Alan Burkhart18-Sep-12 14:46
memberAlan Burkhart18-Sep-12 14:46 
Suggestionthank you Pin
medosalah974-Jul-12 12:15
membermedosalah974-Jul-12 12:15 
QuestionThank you so much Pin
mohammat suyanto20-Jun-12 20:36
membermohammat suyanto20-Jun-12 20:36 
AnswerThanks Pin
Praveen288628-May-12 21:15
memberPraveen288628-May-12 21:15 
QuestionCan you do this for a web page? Pin
haherrera9-Sep-11 7:05
memberhaherrera9-Sep-11 7:05 
QuestionThank you Pin
Sergey Chepurin4-Jul-11 3:04
memberSergey Chepurin4-Jul-11 3:04 
GeneralThanks John this is awesome Pin
altenh3-Dec-10 8:19
memberaltenh3-Dec-10 8:19 
GeneralThanks John Pin
rahulxlash27-Aug-09 21:29
memberrahulxlash27-Aug-09 21:29 
Questionhow to add pen width use text box and user change color use botton Pin
EPPYZA8-Oct-08 10:07
memberEPPYZA8-Oct-08 10:07 
GeneralSystem.OutOfMemoryException occurred in System.Drawing.dll (converted 2005) Pin
yalenap1-Apr-08 13:23
memberyalenap1-Apr-08 13:23 
GeneralRe: System.OutOfMemoryException occurred in System.Drawing.dll (converted 2005) Pin
jkkghjhjgh25-Mar-10 19:12
memberjkkghjhjgh25-Mar-10 19:12 
QuestionHow I erase ? Pin
demon.kiler7-Jun-07 11:44
memberdemon.kiler7-Jun-07 11:44 
AnswerRe: How I erase ? Pin
amit122721-Jun-07 19:39
memberamit122721-Jun-07 19:39 
GeneralRe: How I erase ? Pin
Richard_Faulkner21-Aug-07 13:54
memberRichard_Faulkner21-Aug-07 13:54 
GeneralPaint above /on activexcontrol? [modified] Pin
turbovulc31-Jul-06 5:03
memberturbovulc31-Jul-06 5:03 
QuestionHow can I save content of PictureBox Pin
dragondrache19-Oct-04 5:55
memberdragondrache19-Oct-04 5:55 
AnswerRe: How can I save content of PictureBox Pin
NatBest23-Mar-06 18:53
memberNatBest23-Mar-06 18:53 
AnswerRe: How can I save content of PictureBox Pin
ThaSaint4-Dec-08 3:56
memberThaSaint4-Dec-08 3:56 
GeneralClear PictureBox1 Pin
dragondrache18-Oct-04 7:50
memberdragondrache18-Oct-04 7:50 
GeneralRe: Clear PictureBox1 Pin
loay454528-Apr-06 18:32
memberloay454528-Apr-06 18:32 
Generaldrawing color Pin
Pythorian5-Nov-03 10:51
memberPythorian5-Nov-03 10:51 
AnswerRe: drawing color Pin
Martin Houstrup19-Apr-09 7:04
memberMartin Houstrup19-Apr-09 7:04 
GeneralRe: drawing color Pin
shankarBangalore27-Apr-10 2:43
membershankarBangalore27-Apr-10 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 27 Jul 2003
Article Copyright 2003 by John Buettner
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid