1, the source code
#region Circular label class public class CircleLabel: Label // Inherit the label class to regenerate the solution and you can see me { protected override void OnPaint (PaintEventArgs e) // Reset the shape of the control protected Protect override override { base.OnPaint ( e); // This method occurs every time recursively, to ensure that its shape is a custom shape System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath (); path.AddEllipse (2, 2, this .Width-6, this.Height-6); // Graphics g = e.Graphics; //g.DrawEllipse(new Pen (Color.Red, 2), 2, 2, Width-6, Height-6); Region = new Region (path); } } #endregion
2. Copy to the form code
3. Regenerate
4. Set related properties