![]() ![]() The only difference is that you use a brush rather than a pen for filling shapes. The DrawRectangle and DrawEllipse methods both have counterparts, FillRectangle and FillEllipse. Drawing A Rectangle DrawRectangle( Pen, x, y, width, height)įor example, g.DrawRectangle(Pens.White, 5, 5, 190, 190)Īdd this code and try it out. g.DrawEllipse(Pens.White, 5, 40, 190, 120)Īdd these examples as Case 1 and Case 2 in your Select Case Structure. For example, g.DrawEllipse(Pens.White, 5, 5, 190, 190) To draw a circle, make the height and width the same. The format for drawing an ellipse is as follows, DrawEllipse( Pen, x, y, width, height) X1 and Y1 are the coordinates of the end point of the line. X and Y are the coordinates of the start of the line starting from the top left hand corner of the picture box. The intellisense (the stuff that pops up) makes this object easy to create as you type. There are variations on how to use this function, but it has been used in the example with the following parameters, DrawLine( Pen, x, y, x1, y1)įor more information on Pens and their different uses, check the help. We will start by drawing a simple straight line in white. We can use the Select Case structure to draw different things depending on the user's selection. The variable g will now be a reference to the graphics object that represents the drawing surface of the picture box. ![]() Type the following line first, Dim g As = picShapes.CreateGraphics() Add a listbox called lstShapes and add the items shown in the screenshot below.ĭouble click on the list box and make sure you are typing this code into the SelectedIndexChanged event handler. Start a new project and add a form with a picture box called picShapes which is exactly 200 pixels square and has its background set to black. In this program we will learn how to create a graphics object to draw some shapes on a picture box control. The section of the local help that you can use is called Getting Started with Graphics Programming. Because the topic is so vast, you will always end up using references to find the features that you need to use. ![]() This page is only a gentle introduction to the topic. Visual Basic 2005 has an enormous set of managed code for dealing with graphics. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |