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 }