473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

Oct 16 '07 #1
2 12625
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
Oct 16 '07 #2
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.

--
--
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.
"weird0" <am********@gmail.comwrote in message
news:11**********************@e34g2000pro.googlegr oups.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
Oct 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nanda | last post by:
hi, try this, bmp=new Bitmap(Width,Height); g=Graphics.FromImage(bmp); g.DrawEllipse(Pens.Red, new Rectangle(0, 0, 100, 100)); g.Save();...
4
by: Shalley | last post by:
Hello, there, I have no idea how to draw an ellipse with an rotated angle. For example, the ellipse's center is (20.0, 50.0), two conjugate diameter pairs end-point are (35.0, 35.0), (25.0,...
4
by: Jason Huang | last post by:
Hi, In my C# Windows Form, how do I draw a Line? Thanks for help. Jason
4
by: icek | last post by:
How draw point on picture of map in php
5
by: lgeastwood | last post by:
I have tweaked the PictureBox97.mdb (Stephen Lebans <www.lebans.com>) code to nicely draw lines, rectangles and circles to the specs that I input. I'm at a loss though with trying to setup an...
1
by: sunildani | last post by:
write a program to Draw an ellipse's using polynimial equation ((x-h)^2/a^2 + ((y-k)^2)/b^2 =1
0
by: Tem | last post by:
I need to draw a black circle using WPF and generate an image file. I used the following but it resulted in a blank file. I cannot figure out what is wrong with it. Thanks, Tem ...
4
by: Slickuser | last post by:
I am trying to draw an ellipse with specify x,y,width, and height for input argument in C# .net (Visual Studio 2005). It seem it will not draw for me. What am I missing? See the code below,...
1
by: akiarea | last post by:
Hi Please tell me how to create a bitmap. Draw on it and how to save that bitmap to a bmp file. I done following : on a button click event. CDC* pDC = GetDC(); CDC memDC;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.