Tuesday, 4 February 2014

Round Corner Form in Winforms - C#

In this article we are going to see how to create a rounded corners form in C#, So far that we are going to create a custom form, we can do it in many ways by overriding the Paint method and write customized code, otherwise used the extern method.

C# Code:

public class RoundedBaseForm : Form
        public RoundedBaseForm()
            Region = Region.FromHrgn(CreateRoundRectRgn(50, 50, Height, Width, 480, 250));

        [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn(int LeftRect, int TopRect, int RightRect, int BottomRect, int Width, int Height);


public partial class Form1 : RoundedBaseForm
        public Form1()
            //this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;           
            this.BackColor = Color.FromArgb(255,207, 81);


For value 450 * 250 : Circle

For value 450 * 60 : Cylinder
From this post you can learn how to create a customized Forms.

No comments:

Post a Comment