如何使用花车用的TrackBar花车、如何使用、TrackBar

2023-09-03 02:35:32 作者:毕竟我不是你眼中的唯一

我使用了一个的TrackBar 控制。默认情况下它的值是 INT32 。我真的想使用十进制值,因此使用能够在更细化的级别选择。我怎样才能获得的TrackBar 控制接受花车?

I'm using a TrackBar control. By default its values are int32. I would really like to use decimal values so the use can select at a more granular level. How can I get the TrackBar control to accept floats?

推荐答案

您可以使用的乘数。说,例如,你想使0您的TrackBar控制去 - 5 0.01增量。仅仅通过1设置最低为0,最高为500,递增。

You can use a multiplier. Say, for example, you wanted to make your TrackBar control go from 0 - 5 with 0.01 increments. Just set the Minimum to 0, the Maximum to 500, and increment by 1.

当你去设置你的浮点值,乘以100它,并用它的的TrackBar值。

When you go to set your float value, multiply it by 100, and use that for the TrackBar value.

您应该可以得到precision任何(现实的)程度以这种方式,因为的TrackBar适用于整数,并具有为Int32可使用的全部数据范围。这是更为precision不是用户界面需要。

You should be able to get any (realistic) degree of precision in this manner, since the TrackBar works with ints, and has the full data range of Int32 available. This is much more precision than a user interface requires.