Points

linesSome of the graphics methods use points. A point is a class that has members X and Y. When you declare an instance of the Point or PointF class, you give X and Y as the arguments.
The DrawLine method has 4 possible argument lists.
arguments for DrawLine

The code below uses the fourth format:

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As_
    System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
   Dim MyPoint1 As New Point(e.X - 10, e.Y - 10)
   Dim MyPoint2 As New Point(e.X + 10, e.Y + 10)
   Dim MyPen As New Pen(Color.Goldenrod, 3)
   Me.CreateGraphics.DrawLine(MyPen, MyPoint1, MyPoint2)
End Sub 'Form1_MouseClick

INDEX, Draw a circle, The Brush, Drawing rectangles, Arc and Pie, Array of Points, Drawing Strings: The Font Class, Numbered Dots Project, Numbered Dots Solution
Next lesson: Procedures in Visual Basic

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Drawing rectangles