Circle Drawer
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.
There are no threads for this page.
Be the first to start a new thread.