Solved

How to draw line arrow in C#

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

778 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