I have a window without borders. I searched net for rounded corners but all with borders. How can i make rounded corners of the form(not with borders)
? Is there a way to do that?
I am a newbie to c#, so please explain...
Thanks
I have a window without borders. I searched net for rounded corners but all with borders. How can i make rounded corners of the form(not with borders)
? Is there a way to do that?
I am a newbie to c#, so please explain...
Thanks
try this:
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, // width of ellipse
int nHeightEllipse // height of ellipse
);
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
}
}
}
from here: Form with Rounded Borders in C#?
The Region propery simply cuts off the corners. To have a true rounded corner you will have to draw the rounded rectangles.
It might be easier to draw an image of the shape you want and put that on the transparent form. Easier to draw but cannot be resized.
Also check this Another One
I found this code
To come up with the rounded corners textbox, I started trying to work with the paint override event, but unfortunately without any result, which is due to the fact (I assume) that the textbox is derived from Windows. Therefore, I tried overriding the WM_PAINT API instead, which had the desired results
http://www.codeproject.com/Articles/17453/Textbox-with-rounded-corners
Thanks