Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。












想要改善这个问题吗?更新问题,以便将其作为on-topic用于堆栈溢出。

7年前关闭。



Improve this question




我想在WinForms中有一个圆形按钮控件,我怎么能做到这一点?第三方控件或代码示例就可以了。

最佳答案

您可以轻松地制作自己的作品,Region属性使之变得简单。在您的项目中添加一个新类,并粘贴以下代码。编译。将新控件从工具箱的顶部拖放到窗体上。

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

class RoundButton : Button {
    protected override void OnResize(EventArgs e) {
        using (var path = new GraphicsPath()) {
            path.AddEllipse(new Rectangle(2, 2, this.Width - 5, this.Height - 5));
            this.Region = new Region(path);
        }
        base.OnResize(e);
    }
}

关于c# - 如何获得圆形按钮?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2896342/

10-10 04:05