Line and circles with VB.net 
Author Message
 Line and circles with VB.net

Hi,

Does anyone know where to find a small example with line/circle for
VB.net beta 1 ?

Regards,
Nic



Wed, 04 Jun 2003 20:49:46 GMT  
 Line and circles with VB.net
There are several ways you can go about this. If you want to sdraw
directly on the Form window itself, you can override the OnPaint event
as follows:

Protected Overrides Sub OnPaint(ByVal e as PaintEventArgs)
 Dim g as Graphics = e.Graphics    'get graphics object
 Dim rpen as new Pen(System.Drawing.Color.Black, 1)
 g.DrawLine(rpen, 10,20,70,80)                'a line
 g.DrawRectangle(rpen, 20,30,70,80)        'a rectangle

End Sub

You could also create the pen once outside thsi method.

Another way to do this for any given RichControl c is to hook its paint
handler as follows. During the constructor add the following

AddHandler c.Paint, New PaintEventHandler(AddressOf cPaint)

and have a paint event routine

Public Sub cPaint(Byval sender as Object, Byval e as PaintEventArgs)
 Dim g as Graphics = e.Graphics
 g.DrawLine(rpen, 10,20,70,80)                'a line
End Sub

Here we assume you created rpen somewhere in the constructor.

Hope this is helpful. Please excuse any typos as my VS.Net beta machine
is not my Email machine., and I had ot retype the code.

Jim Cooper



Thu, 05 Jun 2003 01:10:03 GMT  
 Line and circles with VB.net
Do you have codes for drawing inside the picture box?

--
regards/
Jerome Tan

Mobile: +639175277928



Quote:
> There are several ways you can go about this. If you want to sdraw
> directly on the Form window itself, you can override the OnPaint event
> as follows:

> Protected Overrides Sub OnPaint(ByVal e as PaintEventArgs)
>  Dim g as Graphics = e.Graphics    'get graphics object
>  Dim rpen as new Pen(System.Drawing.Color.Black, 1)
>  g.DrawLine(rpen, 10,20,70,80)                'a line
>  g.DrawRectangle(rpen, 20,30,70,80)        'a rectangle

> End Sub

> You could also create the pen once outside thsi method.

> Another way to do this for any given RichControl c is to hook its paint
> handler as follows. During the constructor add the following

> AddHandler c.Paint, New PaintEventHandler(AddressOf cPaint)

> and have a paint event routine

> Public Sub cPaint(Byval sender as Object, Byval e as PaintEventArgs)
>  Dim g as Graphics = e.Graphics
>  g.DrawLine(rpen, 10,20,70,80)                'a line
> End Sub

> Here we assume you created rpen somewhere in the constructor.

> Hope this is helpful. Please excuse any typos as my VS.Net beta machine
> is not my Email machine., and I had ot retype the code.

> Jim Cooper



Thu, 05 Jun 2003 10:38:10 GMT  
 Line and circles with VB.net
Jerome,

Quote:
> Do you have codes for drawing inside the picture box?

The PictureBox control like the Form, is also derived from RichControl, so
exactly the same code applies.

Either create a MyPictureBox control inherited from PictureBox, and override
the OnPaint method.  Or add a PaintEventHandler to the PictureBox control's
Paint event.

--
David.



Thu, 05 Jun 2003 21:38:50 GMT  
 Line and circles with VB.net
It is very unfortunate that something so basic as drawing a line or a circle
has gone from being very easy to rather more complicated then is intuitive.
This is a major step backwards in my opinion. Sometimes I wonder if anyone
working on VB .NET ever used VB 6.0 or earlier.



Quote:
> There are several ways you can go about this. If you want to sdraw
> directly on the Form window itself, you can override the OnPaint event
> as follows:

> Protected Overrides Sub OnPaint(ByVal e as PaintEventArgs)
>  Dim g as Graphics = e.Graphics    'get graphics object
>  Dim rpen as new Pen(System.Drawing.Color.Black, 1)
>  g.DrawLine(rpen, 10,20,70,80)                'a line
>  g.DrawRectangle(rpen, 20,30,70,80)        'a rectangle

> End Sub

> You could also create the pen once outside thsi method.

> Another way to do this for any given RichControl c is to hook its paint
> handler as follows. During the constructor add the following

> AddHandler c.Paint, New PaintEventHandler(AddressOf cPaint)

> and have a paint event routine

> Public Sub cPaint(Byval sender as Object, Byval e as PaintEventArgs)
>  Dim g as Graphics = e.Graphics
>  g.DrawLine(rpen, 10,20,70,80)                'a line
> End Sub

> Here we assume you created rpen somewhere in the constructor.

> Hope this is helpful. Please excuse any typos as my VS.Net beta machine
> is not my Email machine., and I had ot retype the code.

> Jim Cooper



Fri, 06 Jun 2003 05:10:00 GMT  
 Line and circles with VB.net
Many people have wondered this very thing.

--
MichKa

a new book on internationalization in VB at
http://www.i18nWithVB.com/



Quote:
> It is very unfortunate that something so basic as drawing a line or a
circle
> has gone from being very easy to rather more complicated then is
intuitive.
> This is a major step backwards in my opinion. Sometimes I wonder if anyone
> working on VB .NET ever used VB 6.0 or earlier.



> > There are several ways you can go about this. If you want to sdraw
> > directly on the Form window itself, you can override the OnPaint event
> > as follows:

> > Protected Overrides Sub OnPaint(ByVal e as PaintEventArgs)
> >  Dim g as Graphics = e.Graphics    'get graphics object
> >  Dim rpen as new Pen(System.Drawing.Color.Black, 1)
> >  g.DrawLine(rpen, 10,20,70,80)                'a line
> >  g.DrawRectangle(rpen, 20,30,70,80)        'a rectangle

> > End Sub

> > You could also create the pen once outside thsi method.

> > Another way to do this for any given RichControl c is to hook its paint
> > handler as follows. During the constructor add the following

> > AddHandler c.Paint, New PaintEventHandler(AddressOf cPaint)

> > and have a paint event routine

> > Public Sub cPaint(Byval sender as Object, Byval e as PaintEventArgs)
> >  Dim g as Graphics = e.Graphics
> >  g.DrawLine(rpen, 10,20,70,80)                'a line
> > End Sub

> > Here we assume you created rpen somewhere in the constructor.

> > Hope this is helpful. Please excuse any typos as my VS.Net beta machine
> > is not my Email machine., and I had ot retype the code.

> > Jim Cooper



Fri, 06 Jun 2003 05:36:11 GMT  
 Line and circles with VB.net

Quote:
>It is very unfortunate that something so basic as drawing a line or a circle
>has gone from being very easy to rather more complicated then is intuitive.

It's always been this hard, but you were always shielded from it. If
you want PSet, Line and the likes back (what the hell for, but
anyway), you can spend about 10 minutes to dunk them into your own
Form derivative... and use that one ever after.


Sat, 07 Jun 2003 01:15:53 GMT  
 Line and circles with VB.net

Quote:
> It's always been this hard, but you were always shielded from it. If

This is a strange statement. The hard parts were hidden and so it was easy
to draw a line. One did not have to "spend 10 minutes" before. One just
entered a Line statement. And not only that you could draw a line on the
form. You don't seem to be able to do that either. If the change was trivial
then the upgrade wizard would do it. But it doesn't. If I wanted to do
things the hard way I'd still be writing everything in assembler or calling
X Windows libraries.

Quote:
> you want PSet, Line and the likes back (what the hell for, but
> anyway), you can spend about 10 minutes to dunk them into your own
> Form derivative... and use that one ever after.

I could draw lines easier then how VB .NET does it in fortran IV 30 years
ago when I first started programming. This is no improvement. I want it as
simple as it used to be. As they say in Texas, "don't{*filter*}down my back and
tell me it's raining."


Sat, 07 Jun 2003 09:11:22 GMT  
 Line and circles with VB.net
It should be back, even the conversion of VB6 to VB.net fails to convert it
properly, the system fails!

Definitely, this means that VB.net is gearing backward. After a few
complains, do we expect those stuffs back on VB.net version 2.0?

--
regards/
Jerome Tan

Mobile: +639175277928


Quote:
> >It is very unfortunate that something so basic as drawing a line or a
circle
> >has gone from being very easy to rather more complicated then is
intuitive.

> It's always been this hard, but you were always shielded from it. If
> you want PSet, Line and the likes back (what the hell for, but
> anyway), you can spend about 10 minutes to dunk them into your own
> Form derivative... and use that one ever after.



Sat, 07 Jun 2003 16:19:34 GMT  
 Line and circles with VB.net
The reason for this change is the VB7 is now event driven. You can catch and
subclass events to customize them. That is what you now catch the OnPaint method
or add a handler to the Paint event. This is much more powerful and flexible,
but it is certainly a change. It is really a part of the "we want inheritance"
answer. In the long run this will be a terrific improvement, but there is short
term pain.

Jim Cooper



Sat, 07 Jun 2003 23:38:12 GMT  
 Line and circles with VB.net

Quote:
>This is a strange statement. The hard parts were hidden and so it was easy
>to draw a line. One did not have to "spend 10 minutes" before. One just
>entered a Line statement. And not only that you could draw a line on the
>form. You don't seem to be able to do that either. If the change was trivial
>then the upgrade wizard would do it. But it doesn't. If I wanted to do
>things the hard way I'd still be writing everything in assembler or calling
>X Windows libraries.

*sigh*  So would you be okay with _someone else_ spending the 10
minutes for you and posting the code? It'd be worth not hearing stuff
like this over and over and over.


Sun, 08 Jun 2003 00:14:13 GMT  
 Line and circles with VB.net
No, I want the language support that was removed. I want the flexability I
had in VB 6 and earlier.
Quote:
> *sigh*  So would you be okay with _someone else_ spending the 10
> minutes for you and posting the code? It'd be worth not hearing stuff
> like this over and over and over.



Sun, 08 Jun 2003 11:11:36 GMT  
 Line and circles with VB.net

Mayby the main strength of VB was the abilty to rapidly prototype an
application.

So possibly: either Microsoft will find a way to allow the user who did not want
to go into all details and flexibilty to solve rapidly their problems, or they
will have quite some user group sticking to 'old' VB6 ?

Nic


Quote:
> > It's always been this hard, but you were always shielded from it. If

> This is a strange statement. The hard parts were hidden and so it was easy
> to draw a line. One did not have to "spend 10 minutes" before. One just
> entered a Line statement. And not only that you could draw a line on the
> form. You don't seem to be able to do that either. If the change was trivial
> then the upgrade wizard would do it. But it doesn't. If I wanted to do
> things the hard way I'd still be writing everything in assembler or calling
> X Windows libraries.

> > you want PSet, Line and the likes back (what the hell for, but
> > anyway), you can spend about 10 minutes to dunk them into your own
> > Form derivative... and use that one ever after.

> I could draw lines easier then how VB .NET does it in FORTRAN IV 30 years
> ago when I first started programming. This is no improvement. I want it as
> simple as it used to be. As they say in Texas, "don't{*filter*}down my back and
> tell me it's raining."



Sun, 08 Jun 2003 21:33:46 GMT  
 Line and circles with VB.net

Quote:
>No, I want the language support that was removed. I want the flexability I
>had in VB 6 and earlier.

...which you or others can add back in in 10 minutes. Isn't THAT
flexibility?

I'm sorry, but you're being a bit silly.



Mon, 09 Jun 2003 00:01:35 GMT  
 Line and circles with VB.net

Ok, show me this .Net is an improvement. Here is some sample code from VB
6.0. Please demonstrate how you would duplicate it in fewer lines.

Line (Line1.X1 + 5, Line1.Y1 + 5)-(Line4.X2 - 10, Line4.Y2 - 10), vbWhite,
BF

Frankly I think you're the one being silly. Just admit that functionality
has been removed or demonstrate that it hasn't been. Rewrite the line above
in less code and without helper functions and I'll admit you're right.


Quote:

> >No, I want the language support that was removed. I want the flexability
I
> >had in VB 6 and earlier.

> ...which you or others can add back in in 10 minutes. Isn't THAT
> flexibility?

> I'm sorry, but you're being a bit silly.



Mon, 09 Jun 2003 01:19:56 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Create line or circle on user Forms

2. drawing lines and circles

3. Circles and lines

4. Line, Print, Circle, etc. events on a usercontrol

5. Using Circle and Line on TOP of Labels/Text Boxes etc

6. HELP !! Circle and Line methods on Printer Object

7. How do I make a line/circle/box movable

8. Lines & circles

9. Drawing circles on a line

10. Lines, circles object in picture box.

11. Using command line in VB.Net

12. a Simple Horizontal Line in VB.net

 

 
Powered by phpBB® Forum Software