如何使用 WinForms (.NET) 绘制圆角矩形? [英] How to Draw a Rounded Rectangle with WinForms (.NET)?

查看:30
本文介绍了如何使用 WinForms (.NET) 绘制圆角矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#绘制矩形,我需要先在每条边上绘制圆弧,然后我需要点击按钮,它会在边缘绘制圆弧,我该怎么做?

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?

推荐答案

C# 中的图形类没有绘制圆角矩形的内置方法,但是有多种方法可以实现这种效果.Jay Riggs 就从哪里开始提供了很好的建议,另外我建议你看看这篇文章:

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:

所以首先,我们创建一个GraphicsPath,然后我们调用 StartFigure 以便我们可以开始向路径添加边.此代码的其余部分用于顶部左角和顶线圆角矩形.如果我们应该为了使这个角变圆,我们添加一个弧 - 否则...

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...

这篇关于如何使用 WinForms (.NET) 绘制圆角矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆