# Questiondraw circle

#### Akramselwe

##### New member
Hi

I want to create function to draw circle put using this :

nx = x + r *Math.Sin(th * 22 / 7 / 180);
ny = y + r2 *Math.Cos(th * 22 / 7 / 180);

and draw them in picture box using SetPixel method.

Hi

I want to create function to draw circle put using this :

nx = x + r *Math.Sin(th * 22 / 7 / 180);
ny = y + r2 *Math.Cos(th * 22 / 7 / 180);

and draw them in picture box using SetPixel method.
For starters you'll need to put a PictureBox on a form, then handle the Paint event (be sure to use e.Graphics and not create your own) then you can do your drawing.
For circles it's easy as there's a DrawEllipse you can call to have it draw the circle for you, here's an article: How to: Draw Graphics on a Windows Form

Doing it using your own calculus math, I'm not sure how, but I'm sure it can be done.

For starters you'll need to put a PictureBox on a form, then handle the Paint event (be sure to use e.Graphics and not create your own) then you can do your drawing.
For circles it's easy as there's a DrawEllipse you can call to have it draw the circle for you, here's an article: How to: Draw Graphics on a Windows Form

Doing it using your own calculus math, I'm not sure how, but I'm sure it can be done.

Why would you want to use a PictureBox here and not just draw on an existing control, or even create your own?

Drawing a circle is very easy. Just use the following method.
C#:
``[Graphics].DrawEllipse([Pen], [Rectangle]);``

https://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawellipse(v=vs.110).aspx

Why would you want to use a PictureBox here and not just draw on an existing control, or even create your own?

Drawing a circle is very easy. Just use the following method.
C#:
``[Graphics].DrawEllipse([Pen], [Rectangle]);``

https://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawellipse(v=vs.110).aspx
Because the OP stated that he's using a PictureBox.

In reality you can draw on anything in .Net so long as you have a Graphics object to use, for Bitmap objects you can create the Graphics object yourself to use.

Replies
6
Views
967
Replies
3
Views
2K
Replies
1
Views
2K
Replies
3
Views
5K
Replies
2
Views
2K