Click here to Skip to main content
13,189,884 members (50,044 online)
Click here to Skip to main content
Add your own
alternative version


87 bookmarked
Posted 29 Jan 2007

Owner-drawn trackbar(slider)

, 30 Jan 2007
Rate this:
Please Sign up or sign in to vote.
Implementing a Windows Forms owner-drawn trackbar (slider) control in C#.

Sample Image - ColorSlider.gif


This article presents owner-drawn trackbar control. Component is written entirely from scratch. All painting events are done by code. It’s got cool, modern look. The best thing is, however, the capability of changing slider’s thumb shape. It is done simply by providing appropriate graphics path.

Background (optional)

I always wanted to have cool slider for my audio player application. The best I could find here was Guinness4Strength's article. Unfortunately, I didn’t find it pretty enough, so I decided to write my own trackbar. Hopefully you like it.



  • ThumbSize - Gets or sets the size of the thumb
  • ThumbCustomShape - Gets or sets the thumb custom shape. Use ThumbRect property to determine bounding rectangle.
  • ThumbRoundRectSize - Gets or sets the size of the thumb round rectangle edges.
  • BorderRoundRectSize - Gets or sets the size of the border round rect.


  • Orientation - Gets or sets the orientation of Slider.
  • Value - Gets or sets the value of Slider.
  • Minimum - Gets or sets the minimum value.
  • Maximum - Gets or sets the maximum value.
  • SmallChange - Gets or sets trackbar's small change. It affects how to behave when directional keys are pressed
  • LargeChange - Gets or sets trackbar's large change. It affects how to behave when PageUp/PageDown keys are pressed


  • DrawFocusRectangle - Gets or sets a value indicating whether to draw focus rectangle.
  • DrawSemitransparentThumb - Gets or sets a value indicating whether to draw semitransparent thumb.
  • MouseEffects - Gets or sets whether mouse entry and exit actions have impact on how control look.
  • MouseWheelBarPartitions - Gets or sets the mouse wheel bar partitions.


  • ThumbOuterColor - Gets or sets the thumb outer color.
  • ThumbInnerColor - Gets or sets the inner color of the thumb.
  • ThumbPenColor - Gets or sets the color of the thumb pen.
  • BarOuterColor - Gets or sets the outer color of the bar.
  • BarInnerColor - Gets or sets the inner color of the bar.
  • BarPenColor - Gets or sets the color of the bar pen.
  • ElapsedOuterColor - Gets or sets the outer color of the elapsed.
  • ElapsedInnerColor - Gets or sets the inner color of the elapsed.

Points of Interest

This control will provide design-time support. Next version should contain custom properties editors.


  • 30.01.2007 - first version.
  • License

    This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


    About the Author

    Michal Brylka
    Architect Nokia Siemens Networks
    Poland Poland
    Michał is C# and whole .NET enthusiast. He graduated from computer science MSc studies at Wroclaw University of Technology, Poland.

    He is interested in photography and diving. He is member of PADI, currently with divemaster certificate.

    His favorite movies are Matrix, Amélie(Le Fabuleux Destin d'Amélie Poulain), Stargate SG-1 TV Serie and comedies of Mel Brooks.

    Michał lives in Wroclaw, Poland. To contact Michał, email him at michal.brylka[mail-'"at'"-sign]

    You may also be interested in...

    Comments and Discussions

    GeneralRe: Brilliant implementation! Following slight change I did for myself Pin
    Michal Brylka8-Mar-09 8:42
    memberMichal Brylka8-Mar-09 8:42 
    GeneralFantastic! Pin
    -Sean-20-Feb-09 11:38
    member-Sean-20-Feb-09 11:38 
    GeneralRe: Fantastic! Pin
    Michal Brylka8-Mar-09 6:36
    memberMichal Brylka8-Mar-09 6:36 
    QuestionConversion to VB? Pin
    shalan9918-Oct-07 22:59
    membershalan9918-Oct-07 22:59 
    GeneralRe: Conversion to VB? Pin
    Michal Brylka22-Feb-08 2:50
    memberMichal Brylka22-Feb-08 2:50 
    GeneralSlight improvements Pin
    JeromeHordies16-Sep-07 5:07
    memberJeromeHordies16-Sep-07 5:07 
    GeneralRe: Slight improvements Pin
    Michal Brylka14-Feb-08 17:43
    memberMichal Brylka14-Feb-08 17:43 
    GeneralGreat control Pin
    Ross_MacGregor25-Jul-07 8:59
    memberRoss_MacGregor25-Jul-07 8:59 
    This is an excellent control, thanks. I made two small changes for my project. The focus rectangle was being rendered too faintly so I needed to change its color. It may be useful to have its color as a separate color property. I also moved the focus rendering code before the knob rendering because the rectangle was being rendered on top of the knob which did not look right at all.

    Ever think of doing a good bitmap button control? I could use one of those too.

    GeneralMulitple TrackPoints Pin
    bizzysim6-Jul-07 9:36
    memberbizzysim6-Jul-07 9:36 
    GeneralRe: Mulitple TrackPoints Pin
    Michal Brylka6-Jul-07 10:26
    memberMichal Brylka6-Jul-07 10:26 
    NewsGreat Control - added ToolStrip support Pin
    Thomas-H.28-Jun-07 5:08
    memberThomas-H.28-Jun-07 5:08 
    GeneralRe: Great Control - added ToolStrip support [modified] Pin
    Michal Brylka28-Jun-07 7:34
    memberMichal Brylka28-Jun-07 7:34 
    Generalyour control is very good,I want Two blocks in your control, Pin
    frequent30-May-07 18:55
    memberfrequent30-May-07 18:55 
    GeneralRe: your control is very good,I want Two blocks in your control, Pin
    Michal Brylka31-May-07 8:35
    memberMichal Brylka31-May-07 8:35 
    QuestionAccessiblity? Pin
    Zorbek5-Feb-07 21:59
    memberZorbek5-Feb-07 21:59 
    AnswerRe: Accessiblity? Pin
    Michal Brylka7-Feb-07 1:55
    memberMichal Brylka7-Feb-07 1:55 
    GeneralRe: Accessiblity? Pin
    Zorbek7-Feb-07 13:06
    memberZorbek7-Feb-07 13:06 
    GeneralInteresting idea Pin
    Pete O'Hanlon30-Jan-07 0:54
    memberPete O'Hanlon30-Jan-07 0:54 
    GeneralRe: Interesting idea Pin
    Michal Brylka30-Jan-07 15:52
    memberMichal Brylka30-Jan-07 15:52 
    GeneralAdd few thing to become ultimate ;) Pin
    The Monz30-Jan-07 0:42
    memberThe Monz30-Jan-07 0:42 
    GeneralRe: Add few thing to become ultimate ;) Pin
    Michal Brylka7-Feb-07 2:05
    memberMichal Brylka7-Feb-07 2:05 
    GeneralRe: Add few thing to become ultimate ;) Pin
    J.e.e.P21-Apr-09 2:31
    memberJ.e.e.P21-Apr-09 2:31 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.171016.2 | Last Updated 30 Jan 2007
    Article Copyright 2007 by Michal Brylka
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid