Underlined label Control

Source: Internet
Author: User

Underlined label Control

Inherited from label,CodeAs follows:

 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 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.