how to draw arrows in Visual Basic .NET

G

Guest

hi, i would like to draw static arrows in the window form. Seems from the
posts that there isnt any drawing toolbox.

Is there a way of doing it?

Pls go step by step, this is the first time i am programming.
Wish it was as easy as in Microsoft Word where u can just drag an arrow....
Thanks
 
K

Ken Tucker [MVP]

Hi,

In addition to Cor's comments you can draw a line with a endcap set
to an arrowanchor in the forms paint event.

http://msdn.microsoft.com/library/d...tml/frlrfsystemdrawingpenclassendcaptopic.asp

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Dim p As New Pen(Color.Blue, 10)

p.EndCap = Drawing2D.LineCap.ArrowAnchor

p.StartCap = Drawing2D.LineCap.RoundAnchor

e.Graphics.DrawLine(p, 20, 20, 100, 20)

e.Graphics.DrawLine(p, 20, 20, 20, 100)

End Sub



Ken

---------------------

hi, i would like to draw static arrows in the window form. Seems from the
posts that there isnt any drawing toolbox.

Is there a way of doing it?

Pls go step by step, this is the first time i am programming.
Wish it was as easy as in Microsoft Word where u can just drag an arrow....
Thanks
 
H

Herfried K. Wagner [MVP]

Stephen said:
hi, i would like to draw static arrows in the window form.
Seems from the posts that there isnt any drawing toolbox.

Is there a way of doing it?

\\\
Imports System.Drawing
Imports System.Drawing.Drawing2D
..
..
..

' In the form's 'Paint' event handler or 'OnPaint' method...
Dim p As New Pen(Color.Red, 14)
Dim pt1() As Point = { _
New Point(40, 40), _
New Point(120, 40), _
New Point(120, 60) _
}
p.LineJoin = LineJoin.Bevel
p.SetLineCap( _
LineCap.ArrowAnchor, _
LineCap.Round, _
DashCap.Round _
)
e.Graphics.DrawLines(p, pt1)
Dim pt2() As Point = { _
New Point(150, 90), _
New Point(150, 40), _
New Point(200, 40) _
}
p.Color = Color.Blue
p.LineJoin = LineJoin.Round
p.SetLineCap( _
LineCap.Triangle, _
LineCap.RoundAnchor, _
DashCap.Round _
)
e.Graphics.DrawLines(p, pt2)
Dim pt3() As Point = { _
New Point(280, 100), _
New Point(260, 80), _
New Point(260, 40), _
New Point(280, 40), _
New Point(280, 60), _
New Point(220, 60), _
New Point(220, 80) _
}
p.Color = Color.Black
p.LineJoin = LineJoin.Bevel
p.Width = 4
p.SetLineCap( _
LineCap.ArrowAnchor, _
LineCap.DiamondAnchor, _
DashCap.Flat _
)
e.Graphics.DrawLines(p, pt3)
p.Dispose()
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top