Solved

How to draw line arrow in C#

Posted on 2010-08-26
2
2,025 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

Technology Partners: 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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

751 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