Rounded Corner Form in C# Winforms.

Peermohamedmydeen
Posted by Peermohamedmydeen under Windows Forms category on | Points: 40 | Views : 20624
Hi All,

In C# Winforms we can give a rounded corner effect to a form from the following code snippet.

protected void RePaint()
{
GraphicsPath graphicpath = new graphicsPath();
graphicpath.StartFigure();
graphicpath.AddArc(0,0,25,25,180,90);
graphicpath.AddLine(25,0,this.Width-25,0);
graphicpath.AddArc(this.Width-25,0,25,25,270,90);
graphicpath.AddLine(this.Width,25,this.Width,this.Height-25);
graphicpath.AddArc(this.Width-25,this.Height-25,25,25,0,90);
graphicpath.AddLine(this.Width-25,this.height,25,this.Height);
graphicpath.AddArc(0,this.Height-25,25,25,90,90);
graphicpath.CloseFigure();
this.Region = new Region(graphicpath)
}


On every form RePaint() Event, it will draw a rounded corner form.

Thanks and regards
PMM :)

Comments or Responses

Posted by: Sudheep.grandhe on: 12/16/2011 Level:Starter | Status: [Member] | Points: 10
Hi


where i have to write this code in form.whether i have to write this code for every form?
Posted by: Peermohamedmydeen on: 12/16/2011 Level:Bronze | Status: [Member] | Points: 10
No. Not required. If you have a customized user control form. There you can put this.

Login to post response