Windows Develop Bookmark and Share   
 index > Windows Forms General > Ellipsis at design time on a winform - possible ?
 

Ellipsis at design time on a winform - possible ?

Is the draw of an ellipsis at design time on a winform possible in vs2005? (It was in Delphi , VS6)
Virgil Rucsandescu  Thursday, November 02, 2006 7:59 AM
Add a new class to your project, paste the code shown below. Build. Drop an Ellipse from the top of the toolbox to your form.

using System;
using System.Drawing;
using System.Windows.Forms;

public class Ellipse : Panel {
protected override void OnPaint(PaintEventArgs e) {
e.Graphics.FillEllipse(new SolidBrush(this.ForeColor), new Rectangle(0, 0, this.Width, this.Height));
base.OnPaint(e);
}
}


nobugz  Thursday, November 02, 2006 12:15 PM

override the Paint event of control on which you want to draw it, you can do it with form, Panel etc any control you need and just put this code in that:

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint(e);

e.Graphics.DrawEllipse(Pens.Red, 25, 25, this.Width-50, this.Height-50);

}

it'll draw an ellipse in center! You can also creat Thicker Pen to do this.

I hope this will help!

Best Regards,

RizwanSharp  Thursday, November 02, 2006 12:08 PM
Add a new class to your project, paste the code shown below. Build. Drop an Ellipse from the top of the toolbox to your form.

using System;
using System.Drawing;
using System.Windows.Forms;

public class Ellipse : Panel {
protected override void OnPaint(PaintEventArgs e) {
e.Graphics.FillEllipse(new SolidBrush(this.ForeColor), new Rectangle(0, 0, this.Width, this.Height));
base.OnPaint(e);
}
}


nobugz  Thursday, November 02, 2006 12:15 PM

using System;
using System.Drawing;
using System.Windows.Forms;

private void MainForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Pen p = new Pen(Color.Green);
Graphics g = e.Graphics;
g.DrawEllipse(p,20,20,20,20);
}

S.Sriram  Thursday, November 02, 2006 12:20 PM
I think only nobugz really understood my question (all the other solutions are runtime solutions, not design-time.....). I want only to be able to drop and adjust an eclipse (in fact a lot of them) on a form, but at design time (visually - the form should be "beautiful"), not through code ....
And I still didn't test nobugz code ...
Virgil Rucsandescu  Friday, November 03, 2006 5:09 PM

You can use google to search for other answers

Custom Search

More Threads

• Disabled all keys and right click, how do I enable all keys in text box?
• trying to size a Window beyond the Desktop Window size
• Multiple forms
• Convert C# to VB, Backgroundworker
• using selection formula date type field in crystal reports
• Bug in PropertyGrid's Collection Editor
• List View Selected Item Not Scrolling To Selected Row
• Control Contain Certain Points
• Change BackColor of button to the value of a textbox
• MDIContainer