473,394 Members | 1,715 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,394 software developers and data experts.

Draw line VB2005


I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to call the
sub. I want my code to determine the two points then have the sub draw the
line.

Call DrawLinePoint() don't work and I don't know what value to pass it. I
hope I am just missing something simple here.
Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Nov 21 '05 #1
4 5133
<th*****@msala.net> schrieb:
I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to call the
sub. I want my code to determine the two points then have the sub draw
the
line.

Call DrawLinePoint() don't work and I don't know what value to pass it. I
hope I am just missing something simple here.


Place the code in the form's or control's 'Paint' event handler or override
its 'OnPaint' method and perform the drawing there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
<th*****@msala.net> schrieb

I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to
call the sub. I want my code to determine the two points then have
the sub draw the line.

Call DrawLinePoint() don't work and I don't know what value to pass
it. I hope I am just missing something simple here.

'PaintEventArgs' are passed to the Paint event. Handle the event of the
object you want to draw on and pass the argument called 'e' to the sub.
Armin

Nov 21 '05 #3
DrawLinePoint has to handle the form/control's paint event. Otherwise,
it won't display.

th*****@msala.net wrote:
I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to call the
sub. I want my code to determine the two points then have the sub draw the
line.

Call DrawLinePoint() don't work and I don't know what value to pass it. I
hope I am just missing something simple here.
Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Nov 21 '05 #4

I have got it working. I just have to write some code that will only paint
it when I want it. I don't want the line painted everytime the form is
loaded or refreshed.

Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Nov 21 '05 #5

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

Similar topics

5
by: Matt | last post by:
I am writing a recursive program to draw the lines recursively, given the range and number of intervals (n) between the range. The problem is I don't know how to draw the line in point 0.375, as...
2
by: dan heskett | last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some custom "fields" and text layout. Essentially it works, but I must be missing something big, conceptually, because I...
0
by: news | last post by:
If anyone can recommend a more appropriate newsgroup for this question? We recently upgraded from php 4.1.2 to php 4.3.9 and ImageMagick 5.5.7 to version 6.2.5. I have a script that creates a...
4
by: Jason Huang | last post by:
Hi, In my C# Windows Form, how do I draw a Line? Thanks for help. Jason
1
by: Rich | last post by:
Hello, I have a form with a panel which contains a radiobutton. When I click the radiobutton, I invoke the Paint event of the panel using me.Invalidate. The paint event gets called and runs...
1
by: balakrishnan.dinesh | last post by:
Hi frnds, Im creating function to plot line graph in javascript . I have marked the points in graph. but what i need to do is, i want to draw the line between those marked point, but i dont...
1
by: IvoShalev | last post by:
Hi there, I just want to give some sudgestions on how to draw some plain things only using the header file <graphics.hand of course the standart files <stdio.h<conio.h<stdlib.h>. First of All...
3
by: Benson Wong | last post by:
I would like to draw a simple flow chart including Textbox for "Process", lines and arrows for "Flow". Any hints? Benson VB2005, XP Pro, .Net 2.0.
9
by: zhaow | last post by:
Hi, All Greetings! I want to develop as appllication that requires a line-drawing function in the blank area between two forms. I have looked up the MSDN, it says that a graphics object need a...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.