dashed line

falcon

Member
Joined
Oct 21, 2003
Messages
10
Location
Stoke
Hi
i have a picture box and i have drawn a grid using e.graphics, like ruler lines.
does any one know how i can change the code i have so it gives me dashed lines or do i have to manually draw each dash.
heres my code:
Dim x = 30
Do While x < w
e.Graphics.DrawLine(p1, x, 0, x, h)
e.Graphics.DrawLine(p1, 0, x, w, x)
x = x + 30
Loop

thanks for any one who gives info
 
reply

i did it manually, heres the code to any one who needs it.

Dim p1 As New Pen(System.Drawing.Color.Gray, 1)
Dim x = 30
Dim y = 0
Dim z = 0

Do While x < w

Do While y < w
e.Graphics.DrawLine(p1, x, y, x, y + 3)
y = y + 10
Loop
y = 0

Do While z < w
e.Graphics.DrawLine(p1, z, x, z + 3, x)
z = z + 10
Loop

z = 0
x = x + 30
Loop

thanks any way
 
You can specify the line type as:
Code:
        draw dashed interior reference lines
        Dim dashPen As New Pen(Color.LightSteelBlue, 1)
        dashPen.DashStyle = Drawing.Drawing2D.DashStyle.Dash

then to use the line with e.Graphics
Code:
        lineY = 30
        For i = 1 To 21
            e.Graphics.DrawLine(dashPen, centerLine - 70, lineY, centerLine - 10, lineY)
            e.Graphics.DrawLine(dashPen, centerLine + 10, lineY, centerLine + 70, lineY)
            lineY += 20
        Next
        e.Graphics.DrawLine(dashPen, centerLine - 10, 10, centerLine - 10, 430)
        e.Graphics.DrawLine(dashPen, centerLine + 10, 10, centerLine + 10, 430)

Hope that gives you the idea
Dan
 
Back
Top