how to create round corner button in c#.net.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dipankar BiswasRank #992 · 2K reputationPosted May 29, 2015, 2:05 AM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted May 29, 2015, 2:46 AM EDT
http://www.codeproject.com/Articles/15730/RoundButton-Windows-Control-Ever-Decreasing-Circle
Nilesh JadavRank #109 · 20.3K reputationPosted May 29, 2015, 2:46 AM EDT
Nanhe SiddiqueRank #1,103 · 1.7K reputationPosted May 29, 2015, 3:19 AM EDT
Manoj BhoirRank #599 · 4K reputationPosted May 29, 2015, 4:16 AM EDT
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing.Drawing2D;
public class UserControl1
{
//Radius of the Corner Curve
private Int32 _radius = 20;
//Opacity of the Control
private Int32 _opacity = 125;
//Back Color of Control
private System.Drawing.Color _backColor = Color.Black;
private void UserControl1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Rectangle rect = this.ClientRectangle;
//Drawing Rounded Rectangle
rect.X = rect.X + 1;
rect.Y = rect.Y + 1;
rect.Width -= 2;
rect.Height -= 2;
using (GraphicsPath bb = GetPath(rect, _radius)) {
using (Brush br = new SolidBrush(Color.FromArgb(_opacity, _backColor))) {
e.Graphics.FillPath(br, bb);
}
}
}
//Returns the GraphicsPath to Draw a RoundedRectangle
protected GraphicsPath GetPath(Rectangle rc, Int32 r)
{
Int32 x = rc.X;
Int32 y = rc.Y;
Int32 w = rc.Width;
Int32 h = rc.Height;
r = r << 1;
GraphicsPath path = new GraphicsPath();
if (r > 0) {
if ((r > h))
r = h;
if ((r > w))
r = w;
path.AddArc(x, y, r, r, 180, 90);
path.AddArc(x + w - r, y, r, r, 270, 90);
path.AddArc(x + w - r, y + h - r, r, r, 0, 90);
path.AddArc(x, y + h - r, r, r, 90, 90);
path.CloseFigure();
} else {
path.AddRectangle(rc);
}
return path;
}
public UserControl1()
{
Paint += UserControl1_Paint;
}
}
MBGlassButton.dll reference in your project.