Here is a quick control i created which illustrates how this works, you'll
notice that the control is 1 pixel smaller than the region, this allows the
small margin required by the SmoothingMode.AntiAlias, the edges are smooth
and it works for every shape that i've used it for (circles, ellipses,
rounded rectangles...)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace RoundRegionSmoothEdges
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
this.SetStyle(ControlStyles.SupportsTransparentBackColor |
ControlStyles.OptimizedDoubleBuffer , true);
this.BackColor = Color.Transparent;
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath backPath = new GraphicsPath();
GraphicsPath forePath = new GraphicsPath();
backPath.AddEllipse(this.ClientRectangle);
forePath.AddEllipse(new Rectangle(1, 1, this.ClientRectangle.Width - 2,
this.ClientRectangle.Height - 2));
this.Region = new Region(backPath);
e.Graphics.FillPath(Brushes.Blue, forePath);
base.OnPaint(e);
}
}
}