Good on me posting before testing properly.
Post is waiting on moderator approval so cannot edit original reply...
It has a bug (trackbar was drawing too many ticks...) and I cannot edit my post
Here is fixed code
Code:Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) Dim thumbSize = Me.GetThumbRectangle(0, e.Graphics).Size Dim trackRect = Me.GetTrackRectangle(CInt(thumbSize.Width / 2)) Dim ticksRect = trackRect : ticksRect.Offset(0, 15) If Application.RenderWithVisualStyles Then TrackBarRenderer.DrawVerticalTrack(e.Graphics, trackRect) TrackBarRenderer.DrawHorizontalTicks(e.Graphics, ticksRect, Me.Maximum - Me.Minimum + 1, VisualStyles.EdgeStyle.Etched) TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, Me.GetLeftThumbRectangle(e.Graphics), leftThumbState) TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, Me.GetRightThumbRectangle(e.Graphics), rightThumbState) Else ControlPaint.DrawBorder(e.Graphics, trackRect, Color.Gray, ButtonBorderStyle.Inset) Dim TickNum As Integer = Maximum - Minimum If TickNum > 0 Then Dim TickSpace As Double = ticksRect.Width / TickNum For i As Integer = 0 To TickNum Dim tickRect As New Rectangle(ticksRect.X + i * TickSpace, ticksRect.Y, 2, ticksRect.Height) ControlPaint.DrawBorder(e.Graphics, tickRect, Color.Gray, ButtonBorderStyle.Solid) Next End If ControlPaint.DrawButton(e.Graphics, Me.GetLeftThumbRectangle(e.Graphics), GetButtonStateFromThumbState(leftThumbState)) ControlPaint.DrawButton(e.Graphics, Me.GetRightThumbRectangle(e.Graphics), GetButtonStateFromThumbState(rightThumbState)) End If End Sub




Reply With Quote