HeaderPane
Main
Hide
Share Link
Print

Range Mode

With SftSlider.RangeMode set to True, the slider selects a range with two thumbs, for example a price range. SftSlider.LowerValue and SftSlider.UpperValue hold the two ends of the range, SftSlider.MinimumRange the smallest distance between them.

MemberDescription
SftSlider.RangeModeTrue for two thumbs (False by default).
SftSlider.LowerValueThe lower end of the range (0 by default). SftSlider.Value returns the same value in range mode, and setting SftSlider.Value sets LowerValue.
SftSlider.UpperValueThe upper end of the range (10 by default).
SftSlider.MinimumRangeThe smallest distance between the two thumbs (0 by default, so both thumbs can be at the same value).
SftSlider.RangeChangedOccurs when LowerValue or UpperValue changes, by the user or the application. A change of LowerValue raises SftSlider.ValueChanged after it, and so does a change of RangeMode that changes SftSlider.Value.

Setting LowerValue or UpperValue keeps the value set and moves the other end to keep MinimumRange between them: a LowerValue too close to UpperValue raises UpperValue, and an UpperValue too close to LowerValue lowers LowerValue. Only where that would pass SftSlider.Minimum or SftSlider.Maximum is the value set limited. A thumb the user moves stops at MinimumRange from the other one. When the range between SftSlider.Minimum and SftSlider.Maximum is smaller than MinimumRange, the thumbs are as far apart as the slider allows.

C#

sliderPrice.Maximum = 1000;
sliderPrice.TickFrequency = 200;
sliderPrice.SmallChange = 10;
sliderPrice.LargeChange = 100;
sliderPrice.ShowTickLabels = true;
sliderPrice.RangeMode = true;
sliderPrice.MinimumRange = 50;
sliderPrice.LowerValue = 200;
sliderPrice.UpperValue = 600;
sliderPrice.TickLabelFormat = "C0";
sliderPrice.RangeChanged += (s, e) =>
    labelPrice.Text = sliderPrice.LowerValue.ToString("C0") + " to " + sliderPrice.UpperValue.ToString("C0");

VB

SliderPrice.Maximum = 1000
SliderPrice.TickFrequency = 200
SliderPrice.SmallChange = 10
SliderPrice.LargeChange = 100
SliderPrice.ShowTickLabels = True
SliderPrice.RangeMode = True
SliderPrice.MinimumRange = 50
SliderPrice.LowerValue = 200
SliderPrice.UpperValue = 600
SliderPrice.TickLabelFormat = "C0"
AddHandler SliderPrice.RangeChanged, Sub(s, e) LabelPrice.Text = SliderPrice.LowerValue.ToString("C0") & " to " & SliderPrice.UpperValue.ToString("C0")

Using a Range Slider

The user drags either thumb, or drags the band between the thumbs to move both at once with their distance unchanged. A click on the track outside the range moves the nearer thumb by SftSlider.LargeChange. When both thumbs are under the mouse, at the same value or close to it, the direction of the first move decides which one is dragged: toward lower values the lower thumb, otherwise the upper one. A press on a thumb, or a click on the track beside it, gives that thumb the focus, and the keyboard and the mouse wheel move the thumb that has the focus; Tab moves the focus from the lower to the upper thumb and Shift+Tab back before the focus leaves the slider (see Slider Keyboard and Mouse Interface).

Screen readers see each thumb as a slider of its own, with its value and its range (see Accessibility).