Click here to Skip to main content
6,292,811 members and growing! (10,063 online)
Email Password   helpLost your password?
Desktop Development » Selection Controls » General     Intermediate License: The GNU Lesser General Public License

Owner-drawn trackbar(slider)

By Michal Brylka

Implementing a Windows Forms owner-drawn trackbar (slider) control in C#.
C# 2.0, Windows, .NET 2.0VS2005, Dev
Posted:29 Jan 2007
Updated:30 Jan 2007
Views:38,829
Bookmarked:38 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
23 votes for this article.
Popularity: 5.90 Rating: 4.33 out of 5

1
1 vote, 4.3%
2
2 votes, 8.7%
3
4 votes, 17.4%
4
16 votes, 69.6%
5

Sample Image - ColorSlider.gif

Introduction

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.

Properties

Appearance:

  • 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.

Values:

  • 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

Behavior:

  • 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.

Colors:

  • 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.

History

  • 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

    About the Author

    Michal Brylka


    Member
    Michał is C# and whole .NET enthusiast. He studies computer science 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]op.pl.


    Occupation: Database Developer
    Company: ITG S.A.
    Location: Poland Poland

    Other popular Selection Controls articles:

    Article Top
    You must Sign In to use this message board.
    FAQ FAQ 
     
    Noise Tolerance  Layout  Per page   
     Msgs 1 to 25 of 27 (Total in Forum: 27) (Refresh)FirstPrevNext
    GeneralVery cool, small addition I did for myself PinmemberIssaharNoam1:38 22 Mar '09  
    Questionorientation slider value reversed PinmemberTVW0313:11 6 Mar '09  
    AnswerRe: orientation slider value reversed [modified] Pinmembertgpfarm110215:30 7 Mar '09  
    AnswerRe: orientation slider value reversed PinmemberMichal Brylka9:57 8 Mar '09  
    GeneralBrilliant implementation! Following slight change I did for myself PinmemberIssaharNoam1:42 23 Feb '09  
    GeneralRe: Brilliant implementation! Following slight change I did for myself PinmemberMichal Brylka9:42 8 Mar '09  
    GeneralFantastic! Pinmember-Sean-12:38 20 Feb '09  
    GeneralRe: Fantastic! PinmemberMichal Brylka7:36 8 Mar '09  
    QuestionConversion to VB? Pinmembershalan9923:59 18 Oct '07  
    GeneralRe: Conversion to VB? PinmemberMichal Brylka3:50 22 Feb '08  
    GeneralSlight improvements PinmemberJeromeHordies6:07 16 Sep '07  
    GeneralRe: Slight improvements PinmemberMichal Brylka18:43 14 Feb '08  
    GeneralGreat control PinmemberRoss_MacGregor9:59 25 Jul '07  
    GeneralMulitple TrackPoints Pinmemberbizzysim10:36 6 Jul '07  
    GeneralRe: Mulitple TrackPoints PinmemberMichal Brylka11:26 6 Jul '07  
    NewsGreat Control - added ToolStrip support PinmemberThomas-H.6:08 28 Jun '07  
    GeneralRe: Great Control - added ToolStrip support [modified] PinmemberMichal Brylka8:34 28 Jun '07  
    Generalyour control is very good,I want Two blocks in your control, Pinmemberfrequent19:55 30 May '07  
    GeneralRe: your control is very good,I want Two blocks in your control, PinmemberMichal Brylka9:35 31 May '07  
    GeneralAccessiblity? PinmemberZorbek22:59 5 Feb '07  
    GeneralRe: Accessiblity? PinmemberMichal Brylka2:55 7 Feb '07  
    GeneralRe: Accessiblity? PinmemberZorbek14:06 7 Feb '07  
    GeneralInteresting idea PinmemberPete O'Hanlon1:54 30 Jan '07  
    GeneralRe: Interesting idea PinmemberMichal Brylka16:52 30 Jan '07  
    GeneralAdd few thing to become ultimate ;) PinmemberThe Monz1:42 30 Jan '07  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    PermaLink | Privacy | Terms of Use
    Last Updated: 30 Jan 2007
    Editor: Chris Maunder
    Copyright 2007 by Michal Brylka
    Everything else Copyright © CodeProject, 1999-2009
    Web19 | Advertise on the Code Project