Gbates
August 28th, 2009, 09:19 AM
I want to have a form with the shape of a rectangle with rounded corners..
I have found just how to change it to ellipse form..
Thanks!
I have found just how to change it to ellipse form..
Thanks!
|
Click to See Complete Forum and Search --> : Change the shape of the form in C# Gbates August 28th, 2009, 09:19 AM I want to have a form with the shape of a rectangle with rounded corners.. I have found just how to change it to ellipse form.. Thanks! Shuja Ali August 28th, 2009, 03:31 PM I have found just how to change it to ellipse form.. Well that is the same way you change it to rectangle. Just change the image that you are using. It shouldn't be difficult. By the way, welcome to the forum :wave: Gbates August 29th, 2009, 05:32 AM I didn't use an image, I used a code. thanks :P how do I change it with an image? Shuja Ali August 29th, 2009, 09:20 AM Show us what code have you used. Gbates August 30th, 2009, 09:38 AM protected override void OnPaint( System.Windows.Forms.PaintEventArgs e ) { System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath(); shape.AddEllipse(0, 0, this.Width, this.Height); this.Region = new System.Drawing.Region(shape); } Shuja Ali August 30th, 2009, 02:24 PM You can use Shape.AddRectangle to give it a rectangular look. Or you can use a more easier solution. Create the desired image in Paintbrush or a similar application. On the form, set the BackgroundImage property to the new Image that you created. Set the TransparencyKey property to white and FormBorderStyle to none. That is all that you would need to do. toraj58 August 31st, 2009, 05:30 AM for one corner i calculated the coordination and made the upper left corner round-shaped; you can calculate yourself coordination for other three corners and then make them look rounded just adding a few lines of code to my code. just remember to change my coordination when you add other coordination for other three corners. protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath(); Rectangle rect = new Rectangle(50, 0, this.Width, this.Height); Rectangle rect2 = new Rectangle(0, 50, 50, this.Height); shape.AddPie(0, 0, 100, 100, -90, -90); shape.AddRectangle(rect); shape.AddRectangle(rect2); this.Region = new System.Drawing.Region(shape); } codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |