c# winform Label 边框 背景 颜色

2021-01-07 05:27

阅读:619

标签:highlight   border   cti   winform   label   form   elb   oid   send   

  private void label1_Paint(object sender, PaintEventArgs e)
        {
            Label label1 = (Label)sender;
            DrawBorder(label1, e.Graphics, Color.Transparent, label1.Width, label1.Height);

        }

        private Color labelBorderColor = Color.Black;
        private SolidBrush SegBrush; //   功控填充颜色所用brush 
                                     /// 
                                     /// //绘制边框
                                     /// 
                                     /// 
                                     /// lable背景颜色
                                     /// 边框颜色
                                     /// label宽度
                                     /// label高度
        private void DrawBorder(Label label1,System.Drawing.Graphics g, Color color, 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, labelBorderColor, ButtonBorderStyle.Solid);//画个边框
                                                                                          // g.DrawRectangle(pen, myRectangle);
                                                                                          //g.DrawEllipse(pen, myRectangle);
        }

  

c# winform Label 边框 背景 颜色

标签:highlight   border   cti   winform   label   form   elb   oid   send   

原文地址:https://www.cnblogs.com/Betty-IT/p/13157770.html


评论


亲,登录后才可以留言!