473,699 Members | 3,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Draw line VB2005


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

Public Sub DrawLinePoint(B yVal 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.Draw Line(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.c om<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Nov 21 '05 #1
4 5155
<th*****@msala. net> schrieb:
I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(B yVal 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.Draw Line(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(B yVal 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.Draw Line(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.n et wrote:
I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(B yVal 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.Draw Line(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.c om<<<<<<------
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.c om<<<<<<------
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
6489
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 you see below. Please advise! Thanks! #include <iostream> using namespace std;
2
3133
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 get all kinds of screen artifacts and weirdness. My general goal is: list item with a few areas for text, every other item shaded a light color for readability, font color changes with selection. The listbox is populated with custom structurs...
0
1558
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 random number image as a Turing Test, and without changing that, it's stopped working right after the upgrade. But, only part of the mogrify command. Here's the line I'm using:
4
30816
by: Jason Huang | last post by:
Hi, In my C# Windows Form, how do I draw a Line? Thanks for help. Jason
1
2119
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 through code to draw a line. But the line does not draw on the panel until I press either the Alt key or Tab key. Here is my code: Sub rad_Click(...)handles... Me.Invalidate()
1
12717
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 konw how to draw line betwwen the marked points The output for my function will be like this , So the marked point (*) should be connected through lines,
1
15344
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 you have to load drivers for the graphic. -You must have the file EGAVGA.BGI to be in the same directory where your code is. -with this driver you will have 640/480 resolution with 16 colors 1 page or you can choose 320/280 16col with 2 video...
3
1340
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
4023
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 reference to a control or a form. I guess it means that lines can't be draw on blank area between two forms. Can anybody guarantee this for me? Is there any method can realize this function? I mainly want to draw a line from a button in form1 to...
0
8706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9055
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8947
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8902
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7787
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.