Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm
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()
        {
            InitializeComponent();
        }        
 
        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 1:48am
Comments
Sandeep Mewara at 14-Feb-13 7:52am
   
And... the issue is?
Jayanta Chatterjee at 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
good
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.
  Permalink  
Comments
Jayanta Chatterjee at 14-Feb-13 8:05am
   
Thanks a lottttttttttt Sir.....
OriginalGriff at 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
0 CPallini 325
1 Sergey Alexandrovich Kryukov 249
2 OriginalGriff 230
3 George Jonsson 130
4 ChauhanAjay 104
0 OriginalGriff 6,464
1 Sergey Alexandrovich Kryukov 5,915
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
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