开发者

How can I get a round button? [closed]

开发者 https://www.devze.com 2022-12-31 04:40 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

开发者_运维知识库 Improve this question

I would like to have a round button control in WinForms, how might I accomplish this? A third-party control or code sample would be fine.


You can make your own pretty easily, the Region property makes it simple. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto a form.

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);
    }
}


telerik RadButtons for WinForms maybe?

  • Rounded winform Button


add custom drawing in OnPaint event handler.


Use WPF if its still early in the project and you can still switch


I suggest following two DLL files: PresentationCore.dll and PresentationFramework.dll

It's more commonly known as Windows Presentation Foundation (WPF), and can easily be used to make round buttons.


You'd probably have to create an image with your rounded corners specification, and use it on an image button to achieve what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消