Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a round button? [closed]

Tags:

c#

winforms

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.

like image 853
Lisa Avatar asked May 24 '10 10:05

Lisa


People also ask

How do you make a round close button in HTML?

To create a rounded button you have to make use of the border-radius CSS property. The higher the value for that property the more rounder the corners will be. You can use any CSS unit for the boorder-radius property. It can be pixels, ems, rems, percentages etc.

How do you make a button invisible?

xml version = "1.0" encoding = "utf-8" ?> In this code, initially, a variable temp is set to false. Now when the button is clicked, the code satisfies the if condition and makes the button invisible, and the temp value is reversed to true.

What is the round button?

RoundButton is identical to Button, except that it has a radius property which allows the corners to be rounded without having to customize the background.

How do you close a button in CSS?

Close Button CSS 2: Plus You can also create a close button using the plus( + ) symbol. You will need to rotate the plus sign so that it looks like a cancel button.


1 Answers

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);
    }
}
like image 105
Hans Passant Avatar answered Oct 10 '22 14:10

Hans Passant