一、先创建一个组件,继承windows的Label控件

二、重写OnPaint事件

具体请看代码

 public partial class LabelEx : Label
    {
        /// <summary>
        /// 边宽
        /// </summary>
        public int BorderWidth { get; set; } = 1;
        /// <summary>
        /// 边颜色
        /// </summary>
        public Color BorderColor { get; set; } = Color.White;

        public LabelEx()
        {
            InitializeComponent();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            DrawText(e.Graphics);
        }

        private void DrawText(Graphics g)
        {
            g.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
            using (GraphicsPath gp = new GraphicsPath())
            using (Pen outline = new Pen(BorderColor, BorderWidth)
            { LineJoin = LineJoin.Round })
            using (StringFormat sf = new StringFormat())
            using (Brush foreBrush = new SolidBrush(ForeColor))
            {
                gp.AddString(Text, Font.FontFamily, (int)Font.Style,
                    Font.Size, ClientRectangle, sf);
                g.ScaleTransform(1.3f, 1.35f);
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.DrawPath(outline, gp);
                g.FillPath(foreBrush, gp);
            }

        }

    }