Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi how can i Rounding four corners of the TextBox?
i want this for windows form application
Wiht Respect "Spaceman"
Posted
Updated 22-May-19 3:22am
Comments
Mycroft Holmes 19-May-14 23:59pm    
Have some Google Foo - there are many examples including a couple on CP.

Use theses keywords in Google - winforms textbox rounded corners

This is very easy to do in WPF - A Style for Round Glassy WPF Buttons[^]. You will also find more information if you search on the internet.

Windows forms will be more challenging. It can be done though - Rounding the corners of System.Windows.Forms.Control?[^].
 
Share this answer
 
Hi!
I know I'm a bit late, but for anyone who still needs it check -> this vid

Create your own class that inherits from Textbox and apply the code... something like this ->

using System.Windows.Forms;
using System.Drawing;

class round :TextBox
    {
        [System.Runtime.InteropServices.DllImport("gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn
        (
            int nLeftRect, // X-coordinate of upper-left corner or padding at start
            int nTopRect,// Y-coordinate of upper-left corner or padding at the top of the textbox
            int nRightRect, // X-coordinate of lower-right corner or Width of the object
            int nBottomRect,// Y-coordinate of lower-right corner or Height of the object
            //RADIUS, how round do you want it to be?
            int nheightRect, //height of ellipse 
            int nweightRect //width of ellipse
        );
        protected override void OnCreateControl()
        {
            base.OnCreateControl(); 
             this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(2,3,this.Width,this.Height,15,15)); //play with these values till you are happy
}


That's it!
;)
 
Share this answer
 
Comments
Member 14587170 12-Sep-19 1:01am    
code has been not work in visual studio 2019 some i ahve wrote code for class or form event but it does not work
Override paint event of button and draw it yourself, you can use an image too.
 
Share this answer
 
Comments
Avenger1 20-May-14 5:26am    
thanks to all for answer
With Respect "Spaceman"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900