Solved

How to draw line arrow in C#

Posted on 2010-08-26
2
1,992 Views
Last Modified: 2012-05-10
how draw arrowline in usercontrol. i need that middle of the left and bottom.
arrowline.bmp
0
Comment
Question by:YetAnotherCoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Expert Comment

by:jdavistx
ID: 33536589
You override the OnPaint event, which provides you PaintEventArgs and within this you can use PaintEventArgs.Graphics.

Using the the Graphics object you can use methods such as DrawLine() and DrawPolygon.
protected override void OnPaint(PaintEventArgs e)
{
   Graphics g = e.Graphics;
   //Draw your line and triangle here!
}

Open in new window

0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 33536657
Here's a simple example:
protected override void OnPaint(PaintEventArgs e)
{
    Point bottomCorner = new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom);
    Point endPoint = new Point(this.ClientRectangle.Width / 2, this.ClientRectangle.Height / 2);
    Point[] triangle = new Point[3];

    triangle[0] = endPoint;
    triangle[1] = new Point(endPoint.X - 15, endPoint.Y);
    triangle[2] = new Point(endPoint.X, endPoint.Y + 15);
    e.Graphics.DrawLine(Pens.Black, bottomCorner, endPoint);
    e.Graphics.FillPolygon(Brushes.Black, triangle);

    base.OnPaint(e);
}

Open in new window

untitled.JPG
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question