zoukankan      html  css  js  c++  java
  • c# winform Label 边框 背景 颜色

      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 
                                         /// <summary>
                                         /// //绘制边框
                                         /// </summary>
                                         /// <param name="g"></param>
                                         /// <param name="color">lable背景颜色</param>
                                         /// <param name="color">边框颜色</param>
                                         /// <param name="x">label宽度</param>
                                         /// <param name="y">label高度</param>
            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);
            }
    

      

  • 相关阅读:
    [HEOI2015]兔子与樱花
    [HNOI2015]亚瑟王
    [JSOI2011]分特产
    某考试 T3 sine
    [JSOI2015]最小表示
    51NOD 1258 序列求和 V4
    Codeforces 622F The Sum of the k-th Powers
    Loj #6261. 一个人的高三楼
    [HAOI????] 硬币购物
    bzoj4318 OSU!
  • 原文地址:https://www.cnblogs.com/Betty-IT/p/13157770.html
Copyright © 2011-2022 走看看