views:

1058

answers:

1

hello, linking a trackbar and a textfield is very easy in windows forms. it is like this: textBox.DataBindings.Add("Text", trackBar, "Value");

the problem is, that trackbars only allow for integer values but i want to have floating point values. so i usually just divide the value by 100, since on the trackbar the value is not directly visible to the user. but in the textbox it is.

so is it possible to link these two with a factor of 100?

thanks!

+2  A: 

The line of code you have adds a Binding object to the text box's DataBindings collection.

The Binding class has events called Format and Parse, which you can use to perform the division (the Format event takes a value from the trackbar and formats it for the text box) and the multiplication (the Parse event takes a value from the text box and scales it for the trackbar).

Tim Robinson