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
CSS3 Rounded corners are used to add special colored corner to body or text by using the border-radius property.A simple syntax of rounded corners is as follows − #rcorners7 { border-radius: 60px/15px; background: #FF0000; padding: 20px; width: 200px; height: 150px; }
The border-radius CSS property is what adds the rounded corners. You can experiment with different values to get it the way you like. border-radius: 75px; If you want it to be a circle, add border-radius: 50%; .
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.
Drawing 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With