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
 
 
 
 
 
TitleDisplay the available hatch styles in VB .NET
DescriptionThis example shows how to display the available hatch styles in VB .NET. It iterates through the HatchStyle values, displaying examples of each.
KeywordsHatchStyle, hatch style, VB.NET, brush
CategoriesVB.NET, Graphics
 
The program loops through each of the numeric HatchStyle values, calling DrawHatchSample.

Subroutine DrawHatchSample draws the HatchStyle's name and a rectangle filled with that style.

 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    ' Currently the hatch patterns have values 0 to 52.
    Const MIN_PATTERN As Integer = 0
    Const MAX_PATTERN As Integer = 52
    Dim x As Integer = 10
    Dim y As Integer = 10

    For i As Integer = MIN_PATTERN To MAX_PATTERN
        DrawHatchSample(e.Graphics, x, y, CType(i, _
            HatchStyle))
    Next i
End Sub

Private Sub DrawHatchSample(ByVal gr As Graphics, ByRef x _
    As Integer, ByRef y As Integer, ByVal hatch_style As _
    HatchStyle)
    Const TEXT_WID As Integer = 155
    Const RECT_WID As Integer = 30
    Const RECT_HGT As Integer = 20
    Dim br As New HatchBrush(hatch_style, Color.Black, _
        Color.White)
    gr.DrawString( _
        hatch_style.ToString & " (" & CInt(hatch_style) & _
            ")", _
        Me.Font, Brushes.Black, x, y)
    gr.FillRectangle(br, x + TEXT_WID, y, RECT_WID, _
        RECT_HGT)
    gr.DrawRectangle(Pens.Black, x + TEXT_WID, y, RECT_WID, _
        RECT_HGT)

    y += RECT_HGT + 10
    If y + RECT_HGT > Me.ClientSize.Height Then
        x += TEXT_WID + RECT_WID + 30
        y = 10
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated