Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
' Currently the dash styles have values 0 to 5.
Const MIN_PATTERN As Integer = 0
Const MAX_PATTERN As Integer = 5
Dim x As Integer = 10
Dim y As Integer = 10
For i As Integer = MIN_PATTERN To MAX_PATTERN
DrawDashSample(e.Graphics, x, y, CType(i, _
DashStyle))
Next i
End Sub
Private Sub DrawDashSample(ByVal gr As Graphics, ByRef x As _
Integer, ByRef y As Integer, ByVal dash_style As _
DashStyle)
Const TEXT_WID As Integer = 100
Const RECT_WID As Integer = 50
Const RECT_HGT As Integer = 40
Dim the_pen As New Pen(Color.Black)
the_pen.DashStyle = dash_style
gr.DrawString( _
dash_style.ToString & " (" & CInt(dash_style) & _
")", _
Me.Font, Brushes.Black, x, y)
gr.DrawRectangle(the_pen, x + TEXT_WID, y, RECT_WID, _
RECT_HGT)
the_pen.Dispose()
y += RECT_HGT + 10
If y + RECT_HGT > Me.ClientSize.Height Then
x += TEXT_WID + RECT_WID + 30
y = 10
End If
End Sub
|