Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

how to Draw an ellipse using c#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
weird0 - 16 Oct 2007 09:15 GMT
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 - 16 Oct 2007 09:44 GMT
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.EnableVisualStyles();
       Application.Run(new MyForm());
   }
}
class MyForm : Form {
   protected override void OnResize(EventArgs e) {
       base.OnResize(e);
       Invalidate();
   }
   protected override void OnPaint(PaintEventArgs e) {
       base.OnPaint(e);
       e.Graphics.DrawEllipse(SystemPens.ControlText,
ClientRectangle);
   }
}

Marc
Bob Powell [MVP] - 16 Oct 2007 11:20 GMT
You may be interested in the GDI+ FAQ and the Beginners Guide to GDI+ which
can be found on my site.

http://bobpowell.net/beginnersgdi.htm

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

Signature

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

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

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

> 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
[quoted text clipped - 8 lines]
> Need help
> Amir Diwan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.