Click here to Skip to main content
Licence 
First Posted 26 Jul 2003
Views 114,826
Bookmarked 28 times

A Simple VB.NET Freehand Drawing method

By | 26 Jul 2003 | Article
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

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

License

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

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
AnswerThanks PinmemberPraveen288620:15 28 May '12  
QuestionCan you do this for a web page? Pinmemberhaherrera6:05 9 Sep '11  
QuestionThank you PinmemberSergey Chepurin2:04 4 Jul '11  
GeneralThanks John this is awesome Pinmemberaltenh7:19 3 Dec '10  
GeneralThanks John Pinmemberrahulxlash20:29 27 Aug '09  
Questionhow to add pen width use text box and user change color use botton PinmemberEPPYZA9:07 8 Oct '08  
GeneralSystem.OutOfMemoryException occurred in System.Drawing.dll (converted 2005) Pinmemberyalenap12:23 1 Apr '08  
GeneralRe: System.OutOfMemoryException occurred in System.Drawing.dll (converted 2005) Pinmemberjkkghjhjgh18:12 25 Mar '10  
QuestionHow I erase ? Pinmemberdemon.kiler10:44 7 Jun '07  
Hi how do I erase what I drawn ?
AnswerRe: How I erase ? Pinmemberamit122718:39 21 Jun '07  
GeneralRe: How I erase ? PinmemberRichard_Faulkner12:54 21 Aug '07  
GeneralPaint above /on activexcontrol? [modified] Pinmemberturbovulc4:03 31 Jul '06  
QuestionHow can I save content of PictureBox Pinmemberdragondrache4:55 19 Oct '04  
AnswerRe: How can I save content of PictureBox PinmemberNatBest17:53 23 Mar '06  
AnswerRe: How can I save content of PictureBox PinmemberThaSaint2:56 4 Dec '08  
GeneralClear PictureBox1 Pinmemberdragondrache6:50 18 Oct '04  
GeneralRe: Clear PictureBox1 Pinmemberloay454517:32 28 Apr '06  
Generaldrawing color PinmemberPythorian9:51 5 Nov '03  
AnswerRe: drawing color PinmemberMartin Houstrup6:04 19 Apr '09  
GeneralRe: drawing color PinmembershankarBangalore1:43 27 Apr '10  
GeneralRe: drawing color PinmemberMartin Houstrup6:51 27 Apr '10  
GeneralInk Object PinmemberNick Seng16:03 27 Jul '03  

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

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

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