Hello
You'll have to create a GraphicsPath and transform that one.
Bobby
Create a Pen and set its EndCap to be ArrowAnchor, drawing a line with this pen will produce an arrow. GDI+ Pens. Part 1.
'this will draw an simple arrow
'center is the center of the Object (f.e. Me.Width/2)
Dim path As New GraphicsPath()
path.AddPolygon(New Point() {New Point(center, 0), _
New Point(center * 0.9, Me.Height * 0.2), _
New Point(center * 0.97, Me.Height * 0.15), _
New Point(center, Me.Height / 2), _
New Point(center * 1.03, Me.Height * 0.15), _
New Point(center * 1.1, Me.Height * 0.2)} _
)
'rotate it 90° clockwise using the center of the object
Dim rot As New Matrix()
rot.RotateAt(90, New PointF(Me.Width / 2, Me.Height / 2))
path.Transform(rot)
'draw it
e.Grphics.FillPath(Brushes.Black, path)
You can change the line width of the Pen to get a bolder line and larger end cap.@JohnH
Thank's a lot. It is very helpfl. But now I need another kind of EndCap for line of implementation and aggregation. By the way, can I change the size of EndCap? It's very small till I can't see it clearly.
You'd have to manage your point pairs and draw them dynamically with some Paint event, keeping a collection of GraphicsPath seems viable, you should also be able to hittest a MouseDown on each of these paths. Haha.I'm facing another problem now (again). Haha. I need an event that enables me to select the line (class association) and then delete it. I've tried the advice given by Robert and John (thank's a lot for both of you!). This is what I write on my code. I create line first, then I draw it on form by cloning the bitmap object. But in this way, I can only delete the line in sequence order, from the last one. What I want t build is that user can select a line that has been drawed and then they can delete it. Help me.. (again).. Hahaha
If you want to select something you've drawn, then you'll have to process the Click-Event and interpret the Y-Position of the cursor. But I don't really understand what you mean with that you can only delete the last line. Keep the lines in a List or a Collection and you'll be able to delete any line in here.
Bobby
You can change the line width of the Pen to get a bolder line and larger end cap.
You'd have to manage your point pairs and draw them dynamically with some Paint event, keeping a collection of GraphicsPath seems viable, you should also be able to hittest a MouseDown on each of these paths. Haha.