Click here to Skip to main content
13,247,848 members (61,786 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I want to draw a line with rounded start and end point with drawline() method...

My code is -:

using System;
using System.Drawing;
using System.Windows.Forms;
namespace ForPrintPre
    public partial class DigitalClockFriend : Form
        Graphics grx;
        public DigitalClockFriend()
        private void button1_Click(object sender, EventArgs e)
            grx = this.CreateGraphics();
            grx.DrawLine(new Pen(Brushes.Black), 50, 50, 250, 50); 

Thanks in Advance!!!
Posted 14-Feb-13 2:48am
Sandeep Mewara 14-Feb-13 7:52am
And... the issue is?
Jayanta Chatterjee 14-Feb-13 8:01am
It's draw normal line(square start and end point)...
like some arc on start and end point....

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to put a LineCap[^] on the pen:
private void myPanel_Paint(object sender, PaintEventArgs e)
    Graphics g = e.Graphics;
    Pen pen = new Pen(Brushes.Black, 20);
    pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
    g.DrawLine(pen, 50, 50, 100, 100);
Will draw a line with one round, and one square, end.
Jayanta Chatterjee 14-Feb-13 8:05am
Thanks a lottttttttttt Sir.....
OriginalGriff 14-Feb-13 8:14am
You are more than welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100