473,396 Members | 2,036 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.

Drawing One Simple Little Line

Hi,

I remember in VB6 that one could simply draw a line in a picturebox using
the .Line method. There is no equivalent in .NET; everything I read says it
is necessary to do lots of heavily complicated things to get it to happen.

My question is, most of those new methods (the ones that take 25 lines of
code) require that the drawing takes place in the OnPaint event of the
picture box. This seems to imply that whatever is drawn in there must remain
static for the whole program. How can one dynamically change, add, and erase
lines, circles, and so forth during runtime?

May 1 '07 #1
4 2965
"Peter" <st*****@hotmail.comwrote in message
news:bk*****************@newsread4.news.pas.earthl ink.net...
Hi,

I remember in VB6 that one could simply draw a line in a picturebox using
the .Line method. There is no equivalent in .NET; everything I read says
it is necessary to do lots of heavily complicated things to get it to
happen.

My question is, most of those new methods (the ones that take 25 lines of
code) require that the drawing takes place in the OnPaint event of the
picture box. This seems to imply that whatever is drawn in there must
remain static for the whole program. How can one dynamically change, add,
and erase lines, circles, and so forth during runtime?
I don't know how you get 25 lines of code. In the onpaint override just draw
the line using e.Graphics.DrawLine. If you want to change what you're
drawing then just draw a different line in OnPaint.

Michael
May 1 '07 #2
On May 1, 12:26 am, "Peter" <star...@hotmail.comwrote:
Hi,

I remember in VB6 that one could simply draw a line in a picturebox using
the .Line method. There is no equivalent in .NET; everything I read says it
is necessary to do lots of heavily complicated things to get it to happen.

My question is, most of those new methods (the ones that take 25 lines of
code) require that the drawing takes place in the OnPaint event of the
picture box. This seems to imply that whatever is drawn in there must remain
static for the whole program. How can one dynamically change, add, and erase
lines, circles, and so forth during runtime?
You don't have to use the OnPaint override, you can also get the
Graphics object by doing "Dim g as Graphics =
PictureBox.CreateGraphics." And in reality, once you get used to using
GDI+ to do the drawing you will like it better than the VB6 methods
(or at least I do).

Thanks,

Seth Rowe

May 1 '07 #3
On May 1, 5:34 am, rowe_newsgroups <rowe_em...@yahoo.comwrote:
You don't have to use the OnPaint override, you can also get the
Graphics object by doing "Dim g as Graphics =
PictureBox.CreateGraphics." And in reality, once you get used to using
GDI+ to do the drawing you will like it better than the VB6 methods
(or at least I do).
Don't do this. See this article for more information:
http://www.bobpowell.net/picturebox.htm

Also, check out his whole site:

http://www.bobpowell.net

Chris

May 1 '07 #4
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
You don't have to use the OnPaint override, you can also get the
Graphics object by doing "Dim g as Graphics =
PictureBox.CreateGraphics."
How are you going to paint again when it disappears though?
And in reality, once you get used to using
GDI+ to do the drawing you will like it better than the VB6 methods
(or at least I do).
I totally and utterly agree. Dotnet's drawing is *far far* superior. Only
downside is the speed.

Michael
May 2 '07 #5

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

Similar topics

15
by: Remon Huijts | last post by:
Hi there, For a very specific service, I have created a PHP script that uses the GD library functions to create a PNG image from a few lines of XML data describing a simple diagram/drawing. It's...
0
by: Tomi Holger Engdahl | last post by:
I am looking for a solution to add on-line drawing tool to a phpBB discussion board. The idea would be that the users can draw their own simple drawings with the tool and attach them easily as...
9
by: Steve Long | last post by:
Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox. I just want a straight, dotdash line. I have two methods, one works and one doesn't (it cause...
1
by: DBC User | last post by:
Hi Sharpies, This is a very basic question. I am using .Net IDE 2003 and System.Drawing.dll (1.1.4322). I wrote a simple program like this (ommitting the commons) using System.Drawing; .....
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
2
by: mattc66 via AccessMonster.com | last post by:
Does anyone know of some simple line drawing add-on apps. I just need to be able to do some simple line drawing with dims. 4 walls and a door and allow the user to type the dims for the walls. All...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this...
5
by: lazyvlad | last post by:
Hi, I'm writing here because this issue is becoming more annoying with each day it passes. So I have a form, a dataset with a few table adapters (3 to be precise) and a datagridview.The datagridview...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
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...
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,...
0
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...

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.