Solved

How to draw line arrow in C#

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now