Tony Johansson said:
Normally when you create a form it's shape is a rectangle.
Now I want to create a windows form that is not a rectangle but an ellipse
instead
I wonder if anyone have some good example of code where this is done.
There are two ways to do this. The first one has already been mentioned
in another reply, and is based on adding a bitmap to the background and
setting the transparency key of the form to one of the bitmap colors.
Another way is the following:
1. Create an event handler for the form's Paint event, or override the
OnPaint method.
2. Inside this method, create an instance of the GraphicsPath class.
3. Use the various methods of the GraphicsPath, such as AddEllipse or
AddPolygon, to determine the shape of the form.
4. Assign this GraphicsPath object to the Region property of the form.
private void Form1_Paint(object sender, PaintEventArgs e)
{
GraphicsPath gp = new GraphicsPath();
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
rect.Inflate(-4, -4);
gp.AddEllipse(rect);
this.Region = new Region(gp);
}