Advertisement
PatPositron

ScrollingText

Jun 30th, 2013
1,507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.19 KB | None | 0 0
  1. Class ScrollingLabel
  2.     Inherits Label
  3.  
  4.     Private _highlight As Integer
  5.     Private _backcolor As Color = Color.Blue
  6.     Private _forecolor As Color = Color.Yellow
  7.  
  8.     Public Property Highlight() As Integer
  9.         Get
  10.             Return _highlight
  11.         End Get
  12.         Set(ByVal value As Integer)
  13.             _highlight = value
  14.             Invalidate()
  15.         End Set
  16.     End Property
  17.  
  18.     Public Property BackText As Color
  19.         Get
  20.             Return _backcolor
  21.         End Get
  22.         Set(ByVal value As Color)
  23.             _backcolor = value
  24.             Invalidate()
  25.         End Set
  26.     End Property
  27.  
  28.     Public Property HightlightText As Color
  29.         Get
  30.             Return _forecolor
  31.         End Get
  32.         Set(ByVal value As Color)
  33.             _forecolor = value
  34.             Invalidate()
  35.         End Set
  36.     End Property
  37.  
  38.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  39.         MyBase.OnPaint(e)
  40.         Dim G As Graphics = e.Graphics
  41.  
  42.         G.Clear(BackColor)
  43.         G.DrawString(Text, Font, New SolidBrush(_backcolor), 0, 0)
  44.         G.DrawString(Text.Substring(0, _highlight), Font, New SolidBrush(_forecolor), 0, 0)
  45.  
  46.     End Sub
  47.  
  48. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement