# how to draw circle wit radius in .net winfoms

Posted by Shanky11 under Windows Forms on 10/3/2013 | Points: 10 | Views : 1420 | Status : [Member] | Replies : 2
public partial class Circleform : Form
{
public Circleform()
{
InitializeComponent();
}
public class circle
{
public Point startPoint = new Point();
public Point endPoint = new Point();
}
circle l = new circle();
List<circle> allcircle = new List<circle>();

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
foreach (var aLine in allcircle)
{

int dis = (aLine.endPoint.X - aLine.startPoint.X) * (aLine.endPoint.X - aLine.startPoint.X) + (aLine.endPoint.Y - aLine.startPoint.Y) * (aLine.endPoint.Y - aLine.startPoint.Y);

double s = Math.Sqrt(dis);
e.Graphics.DrawEllipse(Pens.Green, aLine.startPoint.X, aLine.startPoint.Y, Convert.ToInt16(s), Convert.ToInt16(s));

}
}

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
{
l = new circle();
l.startPoint = e.Location;

}
}

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
Cursor.Current = Cursors.Cross;
//collect endPoint when mouse moved
if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
{
l.endPoint = e.Location;
//Line completed
this.pictureBox1.Invalidate();

}
}

}
how to find mid point in this to draw a radius

#### Responses

Posted by: Bandi on: 10/3/2013 [Member] [MVP] Platinum | Points: 25
 0 Refer this linkhttp://stackoverflow.com/questions/12344230/how-do-i-draw-a-circle-in-the-middle-of-a-form-and-how-do-i-find-the-circle-centMark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gifShanky11, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Bandi on: 10/3/2013 [Member] [MVP] Platinum | Points: 25
 0 Refer this link for "How do I center a window onscreen in c#?" http://stackoverflow.com/questions/4601827/how-do-i-center-a-window-onscreen-in-chttp://stackoverflow.com/questions/11185980/how-to-find-the-center-of-the-screen-in-any-resolutionhttp://www.dotnettutorials.com/tutorials/graphics/winforms-drawing-cs.aspxMark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gifShanky11, if this helps please login to Mark As Answer. | Alert Moderator
Latest Posts