Jump to content

TUniFormattedNumberEdit: Is it possible to format the number as would the format string #0.00## ?


Roberto Nicchi

Recommended Posts

Hello,

i'm wondering if is possible to set a TUniFormattedNumberEdit object so that it displays the number formatted with 2 decimals (for example) but it allows to insert more decimals (for example 4). Of course if more decimals than two are inserted than all the decimals must be visible. In other words the effect should be that same than the #0.00## display format string.

If it's not possible you could add this as a request for future implementation. Myabe adding a new property to indicate the minimum decimals to format. In my example DecimalPrecision=4 and new property FormatPrecision=2

Thanks

Link to comment
Share on other sites

1 hour ago, Roberto Nicchi said:

i'm wondering if is possible to set a TUniFormattedNumberEdit object so that it displays the number formatted with 2 decimals (for example) but it allows to insert more decimals (for example 4). Of course if more decimals than two are inserted than all the decimals must be visible. In other words the effect should be that same than the #0.00## display format string.

If it's not possible you could add this as a request for future implementation. Myabe adding a new property to indicate the minimum decimals to format. In my example DecimalPrecision=4 and new property FormatPrecision=2

Hello,

Will this option suit you?

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniFormattedNumberEdit1 do
    JSInterface.JSCall('updateNumericFormat', [JSControl.JSObject('aPad:false, aSep: "'+ ThousandSeparator +'", aDec: "'+ DecimalSeparator +'", mDec:' + DecimalPrecision.ToString)]);
end;

 

Link to comment
Share on other sites

15 hours ago, Sherzod said:

Hello,

Will this option suit you?

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniFormattedNumberEdit1 do
    JSInterface.JSCall('updateNumericFormat', [JSControl.JSObject('aPad:false, aSep: "'+ ThousandSeparator +'", aDec: "'+ DecimalSeparator +'", mDec:' + DecimalPrecision.ToString)]);
end;

 

Hello, with this code the value is not formatted at all. It behaves similar to the TuniNumericEdit class.

Don't know if is your code not working or i didn't exaplain well enough. I try with an example:

If the value is 10 the displayed value must me 10.00 ( i want minimal 2 digits)

If the Value is 10.1 the displayed value must me 10.10

If the Value is 10.123 the displayed value must me 10.123

Anyway the user can't insert a value with more than 4 decimals (DecimalPrecision=4) So if the number of decimals are less than 2 i would like to format the value with 2 decimals. If the decimals are more than 2 the value should not be formatted in the decimal part.

thanks

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...