Solved

How to draw line arrow in C#

Posted on 2010-08-26
2
1,802 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
Comment Utility
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 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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