Menu

#5 TCurrencyEdit

open
nobody
None
5
2014-08-25
2002-06-10
No

The TCurrencyEdit does not take the negative currency
format as defined in the regional settings of windows into
account. I suggest to change the implementation of the
method to:

function TCurrencyEdit.DefaultDisplayFormat: string;
var
currStr: string;
I: Integer;
C: Char;
digits, posfmt, negfmt: string;
begin
digits := ',0.' + MakeStr('0', CurrencyDecimals);
currStr := '';
for I := 1 to Length(CurrencyString) do begin
C := CurrencyString[I];
if C in [',', '.'] then currStr := currStr + '''' + C + ''''
else currStr := currStr + C;
end;
if Length(CurrStr) > 0 then
begin
case CurrencyFormat of
0: posfmt := currStr + digits; { '$1' }
1: posfmt := digits + currStr; { '1$' }
2: posfmt := currStr + ' ' + digits; { '$ 1' }
3: posfmt := digits + ' ' + currStr; { '1 $' }
end;
{ Dnote Modification: Added processing of negative
currency setting! }
case NegCurrFormat of
0: negfmt := '(' + currStr + digits + ')'; { '($1)' }
1: negfmt := '-' + currStr + digits; { '-$1' }
2: negfmt := currStr + '-' + digits; { '$-1' }
3: negfmt := currStr + digits + '-'; { '$1-' }
4: negfmt := '(' + digits + currStr + ')'; { '(1$)' }
5: negfmt := '-' + digits + currStr; { '-1$' }
6: negfmt := digits + '-' + currStr; { '1-$' }
7: negfmt := digits + currStr + '-'; { '1$-' }
8: negfmt := '-' + digits + ' ' + currStr; { '-1 $' }
9: negfmt := '-' + currStr + ' ' + digits; { '-$ 1' }
10: negfmt := digits + ' ' + currStr + '-'; { '1 $-' }
11: negfmt := currStr + ' ' + digits + '-'; { '$ 1-' }
12: negfmt := currStr + ' ' + '-' + digits; { '$ -1' }
13: negfmt := digits + '-' + ' ' + currStr; { '1- $' }
14: negfmt := '(' + currStr + ' ' + digits + ')'; { '($ 1)' }
15: negfmt := '(' + digits + ' ' + currStr + ')'; { '(1 $)' }
end;
end;
Result := Format('%s;%s', [posfmt, negfmt]);
end;

- Dnote -

Discussion


Log in to post a comment.