Overriding OnPaint doesn't work at all for whatever reason but I have been successful in handling painting more directly through the Control's Window Procedure.
vbnet Code:
  1. Public Class TrackBarEx
  2.     Inherits TrackBar
  3.  
  4.     Protected Overrides Sub WndProc(ByRef m As Message)
  5.  
  6.         Const WM_PAINT As Integer = &HF
  7.  
  8.         If m.Msg = WM_PAINT Then
  9.  
  10.             'Draw the control as normal
  11.             MyBase.WndProc(m)
  12.  
  13.             'Add a border around it
  14.             DrawControl()
  15.             Exit Sub
  16.         End If
  17.  
  18.         MyBase.WndProc(m)
  19.     End Sub
  20.  
  21.     Private Sub DrawControl()
  22.         Using g As Graphics = Me.CreateGraphics
  23.             DrawBorder(g, Color.Red, 3)
  24.         End Using
  25.     End Sub
  26.  
  27.     Private Sub DrawBorder(ByVal g As Graphics, ByVal c As Color, ByVal thickness As Integer)
  28.         Dim rect As Rectangle = New Rectangle(0, 0, Me.ClientRectangle.Width - 1, Me.ClientRectangle.Height - 1)
  29.  
  30.         Using p As Pen = New Pen(c)
  31.  
  32.             For i = 0 To thickness - 1
  33.                 g.DrawRectangle(p, New Rectangle(i, i, rect.Width - i * 2, rect.Height - i * 2))
  34.             Next
  35.  
  36.         End Using
  37.  
  38.  
  39.     End Sub
  40.  
  41. End Class

Which produces this:-


I've created a derived class that draws a border around the control. There is a slight quirk though. When dragging the control on a Form in design mode, the control renders normally for the duration of the drag operation, effectively ignoring my custom painting code. I have no idea why. However, it seems to work acceptably otherwise.