user1099053
user1099053

Reputation:

FormatFloat in Livebinding

I'm currently trying to use XE5 livebindings to bind a TTrackBar.Value property to a TLabel.text property. The TrackBar has a frequency of 0.1. Unfortunately, what I'm finding is that with the binding in place, the label is displaying increments that aren't exactly 0.1.

For example, if I set the livebinding links 'CustomFormat' property to %s+'x', the label will sometimes display the extended float value, so instead of say displaying 0.6, it'll display something like 0.6004874613100 which makes the UI look messy.

I am aware of the FormatFloat routine, but unfortunately this isn't accepted by the CustomFormat field in the link itself.

Is there any way to format the value so it only displays the short version (i.e. 0.6) instead of the extended value? I know I could manually code it in, but I've got several components in a similar situation and I'd like to use livebindings where possible.

Upvotes: 1

Views: 1090

Answers (1)

AndreaMagni
AndreaMagni

Reputation: 413

You can use something like Format('%%.1f',%s) See Mike Sutton's answer here on SO: Using Format in a livebindings CustomFormat

Upvotes: 2

Related Questions