473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GDI - DrawLine problem....

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
Nov 21 '05 #1
2 2650
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
--
Saber S.

"Stu" <s.****@cergis.com> wrote in message
news:eQ****************@TK2MSFTNGP14.phx.gbl...
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

Nov 21 '05 #2
Stu
Thanks - I am duly embarrasssed and shall not try new stuff drunk again!

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:uq**************@TK2MSFTNGP09.phx.gbl...
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
--
Saber S.

"Stu" <s.****@cergis.com> wrote in message
news:eQ****************@TK2MSFTNGP14.phx.gbl...
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


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jon Cosby | last post by:
I'm using this to draw rectangles in a PictureBox image. Not all of the rectangles are complete, and after drawing several, some of them start disapearing. What's the reason for this? Pen...
3
by: Dan Nash | last post by:
Hi guys I was playing around last nite (as u do, hot coffee in hand) with a simple cube drawing based on an array made up of x,y coords (I know I can use Point but I haven't got that far yet). ...
1
by: Rich | last post by:
Hello, I am trying to draw a graph on a form. I can draw the box using drawline, and bars inside the box using drawrectangle, but when I try to draw a line inside the box the inner lines are...
4
by: Smoke | last post by:
It is possible to draw a line on a control using AA? basically, i need the normal .DrawLine funcion but that support antia aliasing. is this possible? can somebody tellme how? Thanks for the...
2
by: google_groups3 | last post by:
Hi, is it better practise to draw a line on my form using the Graphics.DrawLine command or should I use a label control instead? I am refering to overall speed of the form and amount of memory...
2
by: John | last post by:
I created a number of pictureboxes in a panel, and want to draw lines in those pictureboxes but I cannot. Please see the following code and make corrections. Thanks. Private Sub...
0
by: Lila Godel | last post by:
I am migrating my VB6 GoldMine add-ons to VB.NET to allow for enhancements. I have no problem getting text to print, but I cannot get the 4 PrintPage events that are needed to print a line to work....
3
by: Ben Bush | last post by:
I had the following code and when I clicked the left mouse button one time. I got green line and the second click got a purple line and the green disappeared. I was confused by two questions:...
2
by: intrepid_dw | last post by:
All I am writing a C# WinForms application which is giving me some problems. The application consists of a form containing an empty Tab control to which TabPages are added dynamically (at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.