WinForm form into rounded corners

Source: Internet
Author: User

public void Setwindowregion ()

System.Drawing.Drawing2D.GraphicsPath Formpath;

Formpath = new System.Drawing.Drawing2D.GraphicsPath ();

Rectangle rect = new Rectangle (0, this. Width, this. HEIGHT-22);//this. Left-10,this. Top-10,this. Width-10,this. HEIGHT-10);

Formpath = Getroundedrectpath (rect, 30);

This. Region = new Region (Formpath);


Private GraphicsPath Getroundedrectpath (Rectangle rect, int radius)

int diameter = RADIUS;

Rectangle arcrect = new Rectangle (rect. Location, new Size (diameter, diameter));

GraphicsPath path = new GraphicsPath ();

Upper left corner

Path. AddArc (Arcrect, 180, 90);

upper right corner

Arcrect.x = rect. Right-diameter;

Path. AddArc (Arcrect, 270, 90);

Lower right corner

Arcrect.y = rect. Bottom-diameter;

Path. AddArc (arcrect, 0, 90);

Lower left corner

Arcrect.x = rect. Left;

Path. AddArc (Arcrect, 90, 90);

Path. Closefigure ();

return path;


protected override void OnResize (System.EventArgs e)

This. region = NULL;

Setwindowregion ();


WinForm form into rounded corners

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.