Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleDraw lines with standard start and end caps in VB .NET
DescriptionThis 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.
Keywordsline caps, start cap, end cap, StartCap, EndCap
CategoriesVB.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.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated