Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Draw a Rounded Rectangle with WinForms (.NET)?

Tags:

c#

.net

winforms

Draw rectangle using C# and I need to draw the arc in every edges first of all I draw rectangle and then I need click button it will draw the arc at edges, how can I do it?

like image 925
ratty Avatar asked Dec 28 '09 04:12

ratty


People also ask

What is a rounded rectangle?

A rounded rectangle is the shape obtained by taking the convex hull of four equal circles of radius and placing their centers at the four corners of a rectangle with side lengths and .


1 Answers

The graphics class in C# does not have a built-in method to draw rounded rectangles, however there are several ways that you can accomplish this affect. The links in the answer by Jay Riggs offer good suggestions on where to start, additionally I would suggest that you check out this article:

C# - Creating Rounded Rectangles Using A Graphics Path

So first, we create a GraphicsPath, and then we call StartFigure so that we can start adding edges to the path. The rest of this code is for the top left corner and the top line of the rounded rectangle. If we are supposed to make this corner rounded, we add an arc - otherwise...

like image 101
Tom Neyland Avatar answered Sep 23 '22 07:09

Tom Neyland