Rounded corners to C# win forms

Try this code…
using System.Runtime.InteropServices;

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()
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn( 0 , 0, Width – 10, Height – 10, 20, 20));
// adjust these parameters to get the lookyou want.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s