|
|
Title | Draw lines with standard start and end caps in VB .NET |
Description | This example shows how to draw lines with standard start and end caps in VB .NET. The program sets its Pen's StartCap and EndCap properties. |
Keywords | line caps, start cap, end cap, StartCap, EndCap |
Categories | VB.NET, Graphics |
|
|
Subroutine DrawLineWithCaps draws the lines. It makes a new Pen object and sets its StartCap and EndCap properties. The program then draws with the Pen.
|
|
' Draw a line with the indicated caps.
Private Sub DrawLineWithCaps(ByVal gr As Graphics, ByRef x1 _
As Integer, ByRef x2 As Integer, ByRef y As Integer, _
ByVal cap As LineCap)
Const PEN_WID As Integer = 5
Dim the_pen As New Pen(Color.Black, PEN_WID)
the_pen.StartCap = cap
the_pen.EndCap = cap
gr.DrawLine(the_pen, x1, y, x2, y)
the_pen.Dispose()
y += 4 * PEN_WID
End Sub
|
|
My next book includes a lot more information on Pens, Brushes, and other drawing objects in VS 2005. Check the VB Helper Web site or sign up for my newsletter to learn more about this book when it is available.
|
|
|
|
|
|