C# tutorial-C# drawing ellipses

C# drawing ellipses

To draw an ellipse shape on the control, you can use the drawEllipse() method of the graphic object. The drawEllipse() method requires two parameters. The first parameter is a pen object. The second is the rectangle object.

Example: drawing two ellipses on the form

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;


namespace WindowsFormsApplication2


    public partial class Form2 : Form


        public Form2()






        private void Form2_Paint(object sender, PaintEventArgs e)



            //Create graphic object for the current form

            Graphics gs = this.CreateGraphics();

            //Create pen objects with thick width

            Pen p = new Pen(new SolidBrush(Color.Blue), 10);

            Pen p1 = new Pen(new SolidBrush(Color.Red), 10);

            //Create rectangle objects

            Rectangle rt = new Rectangle(100, 80, 200, 200);

            Rectangle rt1 = new Rectangle(250, 80, 350, 200);

            //Draw ellipses

            gs.DrawEllipse(p, rt);

            gs.DrawEllipse(p1, rt1);




C# to draw ellipses


Mohamed Sirag comment

 Mohamed Sirag

Very interesting tutorial. Thank You : https://siragsoft.com

mojtaba comment




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.