Label控件边框颜色

using System.Drawing;

private void label1_Paint(object sender, PaintEventArgs e)
        {
          
           DrawBorder(e.Graphics, Color.Red,Color.Blue, label1.Width, label1.Height);

         }

       
          private SolidBrush SegBrush; //   功控填充颜色所用brush 
        /// 
         /// //绘制边框
        /// 
        /// 
         /// lable背景颜色
         /// 边框颜色
        /// label宽度
        /// label高度
        private void DrawBorder(System.Drawing.Graphics g,Color color,Color bordercolor,int x,int y) 
        {
   

            SegBrush = new SolidBrush(color);
            Pen pen = new Pen(SegBrush, 1);
            //e.Graphics.FillRectangle(SegBrush, RcTime);

            label1.BorderStyle = BorderStyle.None;
            label1.BackColor = color;

            pen.Color = Color.White;

            Rectangle myRectangle = new Rectangle(0, 0, x, y);
            ControlPaint.DrawBorder(g, myRectangle, bordercolor, ButtonBorderStyle.Solid);//画个边框
           // g.DrawRectangle(pen, myRectangle);
            //g.DrawEllipse(pen, myRectangle);
        }

你可能感兴趣的:(c#)