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
________________________________________
^------^
-
You can draw your own using
ControlPaintto make sure the rendering is consistent with the rest of your UI.Presidenten : I have never used ControlPaint before. Could you describe in a little more detail how it would be done? -
You can do this by writing your own
UserControlwhere 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
ControlPaintand the theming APIs provided by theSystem.Windows.Forms.VisualStylesnamespace. Most notably, theVisualStyleElement.TrackBar.ThumbTop,VisualStyleElement.TrackBar.ThumbBottom, andVisualStyleElement.TrackBar.Trackfor drawing the thumbs and track respectively.You use the
ControlPaintcalls to draw a frame and buttons for the track and thumbs when theming is unavailable (such as on Win2k or when theming is disabled).Presidenten : I have not done anything like this before. If I draw everything my self, is there any way to still get the "standard" behaviour for the tumbs and ticks, or would I have to design that as well?Jeff Yates : Unfortunately, you would need to design and code that yourself. There are visual styles for drawing the ticks when theming is available, but you are responsible for determining the layout, handling keyboard and mouse interaction, etc.
0 comments:
Post a Comment