how to Draw an ellipse using c#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • weird0

    how to Draw an ellipse using c#

    I wanted to draw an ellipse using c# with System.Drawing. Graphics. I
    tried out several tutorials and none of them worked and there seems to
    be something missing. One did execute without any errors but it did
    not render an ellipse on the form.

    I want to create an ellipse with just a new project with one form
    default, that is Form1. I want the draw ellipse function to be in some
    other class,say Shapes( user-defined) and then call it in the form1
    class. How can i do this successgully? I tried hell lot of stuff.

    Need help
    Amir Diwan

  • Marc Gravell

    #2
    Re: how to Draw an ellipse using c#

    Well, drawing an ellipse is easy - but you need to be a bit clearer on
    your context; perhaps post what isn't working? But following works:

    static class Program {
    static void Main() {
    Application.Ena bleVisualStyles ();
    Application.Run (new MyForm());
    }
    }
    class MyForm : Form {
    protected override void OnResize(EventA rgs e) {
    base.OnResize(e );
    Invalidate();
    }
    protected override void OnPaint(PaintEv entArgs e) {
    base.OnPaint(e) ;
    e.Graphics.Draw Ellipse(SystemP ens.ControlText ,
    ClientRectangle );
    }
    }

    Marc


    Comment

    • Bob Powell [MVP]

      #3
      Re: how to Draw an ellipse using c#

      You may be interested in the GDI+ FAQ and the Beginners Guide to GDI+ which
      can be found on my site.



      For the GDI+ FAQ see the link in my signature.

      --
      --
      Bob Powell [MVP]
      Visual C#, System.Drawing

      Ramuseco Limited .NET consulting


      Find great Windows Forms articles in Windows Forms Tips and Tricks


      Answer those GDI+ questions with the GDI+ FAQ


      All new articles provide code in C# and VB.NET.
      Subscribe to the RSS feeds provided and never miss a new article.


      "weird0" <amirediwan@gma il.comwrote in message
      news:1192522535 .846749.230220@ e34g2000pro.goo glegroups.com.. .
      I wanted to draw an ellipse using c# with System.Drawing. Graphics. I
      tried out several tutorials and none of them worked and there seems to
      be something missing. One did execute without any errors but it did
      not render an ellipse on the form.
      >
      I want to create an ellipse with just a new project with one form
      default, that is Form1. I want the draw ellipse function to be in some
      other class,say Shapes( user-defined) and then call it in the form1
      class. How can i do this successgully? I tried hell lot of stuff.
      >
      Need help
      Amir Diwan
      >

      Comment

      Working...