Click here to Skip to main content
Click here to Skip to main content

Owner-drawn trackbar(slider)

, 30 Jan 2007 LGPL3
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]

    Comments and Discussions

    GeneralExactly what I needed! PinmemberMember 1073315012-Oct-14 6:50 
    SuggestionGreat control - some suggestions Pinmemberdr_thomas1-May-13 5:01 
    QuestionthumbCustomShape PinmemberUltiblade11-Mar-13 4:54 
    QuestionVertical orientation - reversed Pinmemberthewampek5-Feb-13 6:09 
    SuggestionAdding ColorSlider to the VB ToolBox PinmemberRavinduL27-Dec-12 21:37 
    Yes, the ColorSlider is a very nice variation of the TrackBar. You can add that as an element to the Visual Basic toolbox. Heres how;
    1. Download the 'demo project (binary only)' which is 24 kb is size.
    ► You download that as a WinRAR zip archive so, you need to have an archiving program to extract it to your computer.
    ► There will be 2 files in the archive.
    ► One is an application (.exe (executable)) and the other is a .dll file.
    ► Note that when you delete the .dll file, the application does not work.
    2. Add it to your VB toolbox.
    ► To do this, open Visual Basic, create a new project and dock the whole program to a side.
    ► Next go to the place you extracted the 'demo project (binary only)' 24 kb archive.
    ► Make sure the VB toolbox is Visible.
    ► Drag & Drop the .dll file to your VB toolbox. Then, a new element names 'ColorSlider' will appear.
    ► You can now customize, and use this on your projects.
    Name - Ravindu Liyanapathirana
    Website -
    YouTube channel -
    Channel E-mail -
    Personal E-mail -

    Questionimage as pen? PinmemberAndres Santillan20-Sep-12 19:01 
    GeneralMy vote of 5 PinmemberMember 90334004-Jun-12 7:04 
    QuestionNice work thanks. My vote is 5 PinmemberIssaharNoam11-Jan-12 23:18 
    QuestionPanel scrolls on mouse wheel before trackbar Pinmemberhowardfarrar27-Sep-10 7:21 
    AnswerRe: Panel scrolls on mouse wheel before trackbar Pinmemberhowardfarrar28-Sep-10 2:13 
    GeneralMy vote of 5 PinmemberXmen W.K.16-Jul-10 16:48 
    Generalgood control Pinmembersecurigy19-Jun-10 1:29 
    GeneralVery cool, small addition I did for myself PinmemberIssaharNoam22-Mar-09 1:38 
    GeneralRe: Very cool, small addition I did for myself PinmemberXmen W.K.16-Jul-10 16:50 
    Questionorientation slider value reversed PinmemberTVW036-Mar-09 13:11 
    AnswerRe: orientation slider value reversed [modified] Pinmembertgpfarm11027-Mar-09 15:30 
    GeneralRe: orientation slider value reversed [modified] PinmemberMark Cortejo24-Jul-14 15:55 
    AnswerRe: orientation slider value reversed PinmemberMichal Brylka8-Mar-09 9:57 
    GeneralBrilliant implementation! Following slight change I did for myself PinmemberIssaharNoam23-Feb-09 1:42 
    GeneralRe: Brilliant implementation! Following slight change I did for myself PinmemberMichal Brylka8-Mar-09 9:42 
    GeneralFantastic! Pinmember-Sean-20-Feb-09 12:38 
    GeneralRe: Fantastic! PinmemberMichal Brylka8-Mar-09 7:36 
    QuestionConversion to VB? Pinmembershalan9918-Oct-07 23:59 
    GeneralRe: Conversion to VB? PinmemberMichal Brylka22-Feb-08 3:50 
    GeneralSlight improvements PinmemberJeromeHordies16-Sep-07 6:07 

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

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

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