Circle DrawerThis is a featured page

This tutorial will show how to make a windows forms application that allows the user to draw circles on the form.

First create a new windows forms application (file/new) and then add a picturebox to it from the toolbar on the left, then add a 4 textboxes, a color dialog, and one button. make the text of the four textboxes the following by choosing text from the properties toolbox on the right:
"x"
"y"
"Width"
"Height"

then make the text for the button say
"Draw"

Now go to the code for the form and add the following code inside the class form1, but outside of the form1_load sub:

dim ggraphics as graphics
dim gbitmap as bitmap

dim circle_x as integer
dim circle_y as integer
dim circle_width as integer
dim circle_height as integer

and add the following within the form1_load sub:

gbitmap = new bitmap(picturebox1.width, picturebox1.height)
ggraphics = graphics.fromimage(gbitmap)
picturebox1.backgroundimage = gbitmap


And then add this code to the button that says "Draw":

circle_x = conversion.int(textbox1.text)
circle_y = conversion.int(textbox2.text)
circle_width = conversion.int(textbox3.text)
circle_height = conversion.int(textbox4.text)


ggraphics.drawellipse(pens.blue, circle_x, circle_y, circle_width, circle_height)

picturebox1.update()
picturebox1.refresh()



With this program, users can fill out the form and click "Draw' to draw a blue circle on the screen.



Mrgameruler
Mrgameruler
Latest page update: made by Mrgameruler , May 10 2008, 11:36 PM EDT (about this update About This Update Mrgameruler Edited by Mrgameruler

201 words added

view changes

- complete history)
Keyword tags: tutorial vb.net
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)