GDI - DrawLine problem....

S

Stu

Hi,

Why does the code below only draw the last line of the loop? I was expecting
this to draw 10 parallel lines. More to the piont....how do I get it to draw
10 parallel lines?

Public Function GetImage() As Bitmap
Dim oBitmap As Bitmap = New Bitmap(200, 200)
Dim oGraphic As Graphics = Graphics.FromImage(oBitmap)
Dim oPen As New Pen(Color.Black, 4)
Dim i As Integer
For i = 0 To 10
oGraphic.DrawLine(oPen, i, 0, i, 150)
Next
Return oBitmap
End Function

Thanks in advance,

Stu
 
S

Saber

It doesn't draws only last line of the loop, since in your loop there is no
distance between lines it seems like a thick line.
use something like this loop to draw 10 parallel lines:
For i = 1 To 10
oGraphic.DrawLine(oPen, i * 15, 0, i * 15, 150)
Next

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top