How To Make A Round Button In C#

round button for c#
Someone has asked me how to make a round button in c#, if I am right it's really easy to make round button with, I didn't have time to do something really advanced, I made something really simple. All you have to do is just create a new class and add all these codes into your class.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

class Round : Button
    protected override void OnCreateControl()
        using (var path = new GraphicsPath())
            path.AddEllipse(new Rectangle(2, 2, this.Width - 5, this.Height - 5));
            this.Region = new Region(path);
Just build the project or debug and look for a new tool in your toolbox
toolbox new tool rectangle button
You can add it to your form and use it, by the way I recommend you to use this button also please change the width and other sizes for your needs. 


Post a Comment

Note: Only a member of this blog may post a comment.