zoukankan      html  css  js  c++  java
  • 带下划线的LABEL控件

    带下划线的LABEL控件

    继承自Label,代码如下:

      1 using System.Drawing.Drawing2D;
      2 using System.Windows.Forms;
      3 using System.Collections.Generic;
      4 using System.ComponentModel;
      5 using System.Linq;
      6 using System.Text;
      7 
      8 namespace CustomControlSample
      9 {
     10     public class LineLabel:System.Windows.Forms.Label
     11     {
     12         private Color _lineColor;
     13         private float _lineThick;
     14         private float[] _DashPattern;
     15         private DashStyle _DashStyle;
     16 
     17         public LineLabel()
     18         {
     19             _lineColor = base.ForeColor;
     20             _lineThick = 1f;
     21             _DashStyle = DashStyle.Solid;
     22         }
     23 
     24         [Browsable(true)]
     25         public Color LineColor
     26         {
     27             get
     28             {
     29                 return _lineColor;
     30             }
     31             set
     32             {
     33                 _lineColor = value;
     34                 Invalidate();
     35             }
     36         }
     37 
     38         [Browsable(true)]
     39         public float LineThick
     40         {
     41             get
     42             {
     43                 return _lineThick;
     44             }
     45             set
     46             {
     47                 _lineThick = value;
     48                 Invalidate();
     49             }
     50         }
     51 
     52         [Browsable(true)]
     53         public float LinePenMode
     54         {
     55             get
     56             {
     57                 return _lineThick;
     58             }
     59             set
     60             {
     61                 _lineThick = value;
     62                 Invalidate();
     63             }
     64         }
     65 
     66         [Browsable(true)]
     67         public float[] LineDashPattern
     68         {
     69             get
     70             {
     71                 return _DashPattern;
     72             }
     73             set
     74             {
     75                 _DashPattern = value;
     76                 Invalidate();
     77             }
     78         }
     79 
     80         [Browsable(true)]
     81         public DashStyle LineDashStyle
     82         {
     83             get
     84             {
     85                 return _DashStyle;
     86             }
     87             set
     88             {
     89                 _DashStyle = value;
     90                 Invalidate();
     91             }
     92         }
     93 
     94         protected override void OnPaint(PaintEventArgs e)
     95         {
     96             base.OnPaint(e);
     97             //StringFormat style = new StringFormat();
     98             //e.Graphics.DrawString(
     99             //    base.Text,
    100             //    Font,
    101             //    new SolidBrush(base.ForeColor),
    102             //    ClientRectangle, style);
    103 
    104             Pen p = new Pen(LineColor, LineThick);
    105             p.DashStyle = LineDashStyle;
    106             if ((p.DashStyle == DashStyle.DashDot) || (p.DashStyle == DashStyle.DashDotDot))
    107                 p.DashPattern = LineDashPattern;
    108             e.Graphics.DrawLine(p,2,this.Height-1, this.Width,this.Height-1);
    109         }
  • 相关阅读:
    android手机rootROM下载地址
    mysql alter 语句用法,添加、修改、删除字段等
    java比较两个日期大小
    eclipse设置全局编码为UTF-8的方法
    Spring MVC 异步处理请求,提高程序性能
    ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台
    maven之发布项目到nexus【clean deploy命令】
    nexus-3本地下载jar的settipng.xml配置
    windows开启3306端口并用可视化工具访问远程mysql(授权访问)
    mysql 列转行,合并字段
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2839656.html
Copyright © 2011-2022 走看看