Search code examples
c#winformstrackbar

How can I change the tick frequency in trackbar to a decimal?


I am trying to set the trackbar's tick frequency to 0.015625.

private void trackBar1_Scroll(object sender, EventArgs e) {           
    ScrollBar.TickFrequency = 0.015625;
}

I am getting an error that says:

Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (Are you missing a cast?)

And:

Cannot convert method group 'ToDouble' to non-delegate type 'int'. Did you intend to invoke the method?

Can someone explain that means or what I'm doing wrong?

Edit: I found the answer to my question.

Demo.Property = (ScrollBar.Value * (Rate));

In my case I used:

Demo.Inches = (ScrollBar.Value * 0.015625);


Solution

  • It was designed as an int, just like the Min, Max and Value properties.

    You will have to calculate your own scaling here. By setting Max to a multiple of 64 for instance.