Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple slider trackbar for windows forms

Tags:

c#

winforms

Does anyone have any idea on how to create a trackbar with multiple sliders in WinForms? I would like to mark a range. Also, is it possible to offset the sliders vertically a little bit? My goal would be to have two sliders above the trackbar, and two below it.

     v-----------------v
________________________________________
                                ^------^
like image 663
Presidenten Avatar asked Feb 24 '09 12:02

Presidenten


1 Answers

You can do this by writing your own UserControl where you handle the mouse events and painting yourself. You would need several hit test regions; one for each thumb.

To draw the trackbar, you would need a combination of ControlPaint and the theming APIs provided by the System.Windows.Forms.VisualStyles namespace. Most notably, the VisualStyleElement.TrackBar.ThumbTop, VisualStyleElement.TrackBar.ThumbBottom, and VisualStyleElement.TrackBar.Track for drawing the thumbs and track respectively.

You use the ControlPaint calls to draw a frame and buttons for the track and thumbs when theming is unavailable (such as on Win2k or when theming is disabled).

like image 122
Jeff Yates Avatar answered Sep 24 '22 15:09

Jeff Yates