I want to have a form with the shape of a rectangle with rounded corners..
I have found just how to change it to ellipse form..
Thanks!
Printable View
I want to have a form with the shape of a rectangle with rounded corners..
I have found just how to change it to ellipse form..
Thanks!
I didn't use an image, I used a code.
thanks :P
how do I change it with an image?
Show us what code have you used.
protected override void OnPaint( System.Windows.Forms.PaintEventArgs e )
{
System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
shape.AddEllipse(0, 0, this.Width, this.Height);
this.Region = new System.Drawing.Region(shape);
}
You can use Shape.AddRectangle to give it a rectangular look. Or you can use a more easier solution.
Create the desired image in Paintbrush or a similar application. On the form, set the BackgroundImage property to the new Image that you created. Set the TransparencyKey property to white and FormBorderStyle to none. That is all that you would need to do.
for one corner i calculated the coordination and made the upper left corner round-shaped; you can calculate yourself coordination for other three corners and then make them look rounded just adding a few lines of code to my code. just remember to change my coordination when you add other coordination for other three corners.
Code:protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
Rectangle rect = new Rectangle(50, 0, this.Width, this.Height);
Rectangle rect2 = new Rectangle(0, 50, 50, this.Height);
shape.AddPie(0, 0, 100, 100, -90, -90);
shape.AddRectangle(rect);
shape.AddRectangle(rect2);
this.Region = new System.Drawing.Region(shape);
}