3

I added a trackbar on a Winform project with C#.

mySlider.Minimum = 0;
mySlider.Maximum = 200;
mySlider.Value = 30;
mySlider.SmallChange = 10;
mySlider.LargeChange = 10;
mySlider.TickFrequency = 10;

I would like to be able to select only ten multiples value.
I don't found a solution in order to do this.

What's the best way please ?

Dmitry
  • 13,797
  • 6
  • 32
  • 48
Walter Fabio Simoni
  • 5,671
  • 15
  • 55
  • 80
  • You can make it in [0;20] range and multiply value by 10. – Ulugbek Umirov Apr 21 '14 at 17:52
  • possible duplicate of [How to set value of .Net trackbar control with mouse, does not set value detween two points?](http://stackoverflow.com/questions/18634269/how-to-set-value-of-net-trackbar-control-with-mouse-does-not-set-value-detween) – Cody Gray - on strike Apr 21 '14 at 17:56

1 Answers1

3

Since the TrackBar control hasn't any labels, you could use it for entering values and then multiply entered value by 10. For instance:

mySlider.Minimum = 0;
mySlider.Maximum = 20;
mySlider.Value = 3;
mySlider.SmallChange = 1;
mySlider.LargeChange = 1;
mySlider.TickFrequency = 1;

But labels for the minimum and the maximum should display values multiplied by 10.
And when entered value is requested, simply multiply it by 10:

int someValue = mySlider.Value * 10;
Dmitry
  • 13,797
  • 6
  • 32
  • 48