Hunter Mitchell Hunter Mitchell - 1 year ago 119
C# Question

Form with Rounded Borders in C#?

I am using this code to make the form have no border style:

this.FormBorderStyle = FormBorderStyle.None;

I need to make rounded edges on the form.

Is there an easy way? How do I do it?

Answer Source

Here's a full form class which implements the answer in my comment

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
    public partial class Form1 : Form
        [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn
            int nLeftRect, // x-coordinate of upper-left corner
            int nTopRect, // y-coordinate of upper-left corner
            int nRightRect, // x-coordinate of lower-right corner
            int nBottomRect, // y-coordinate of lower-right corner
            int nWidthEllipse, // height of ellipse
            int nHeightEllipse // width of ellipse

        public Form1()
            this.FormBorderStyle = FormBorderStyle.None;
            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download