RobYost Posted February 11, 2017 Share Posted February 11, 2017 Does anyone know how to have a edit field only accept currency? I currently use TcxCurrencyEdit, (DevExpress) but obviously that wont work. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 12, 2017 Share Posted February 12, 2017 Hi, You can use TUniNumberEdit, TUniFormattedNumberEdit See a demo example: \FMSoft\Framework\uniGUI\Demos\Desktop\FormattedEdit Best regards. Quote Link to comment Share on other sites More sharing options...
RobYost Posted February 12, 2017 Author Share Posted February 12, 2017 Thanks. I made a new control that uses the system configuration of currency if anyone is interested. I'm new to controls, so if you see a problem with this let me know. unit UniCurrencyEdit;interfaceuses SysUtils, Classes, uniGUIBaseClasses, uniGUIClasses, uniEdit;type TUniCurrencyEdit = class(TUniFormattedNumberEdit) private protected { Protected declarations } public constructor Create(AOwner: TComponent); override; published end;procedure Register;implementationconstructor TUniCurrencyEdit.Create(AOwner: TComponent);begin inherited; case (formatsettings.CurrencyFormat) of 0: begin FormattedInput.CurrencySignPos := cpsLeft; FormattedInput.CurrencySignSpace := crsNone; end; 1: begin FormattedInput.CurrencySignPos := cpsRight; FormattedInput.CurrencySignSpace := crsNone; end; 2: begin FormattedInput.CurrencySignPos := cpsLeft; FormattedInput.CurrencySignSpace := crsAvailable; end; 3: begin FormattedInput.CurrencySignPos := cpsRight; FormattedInput.CurrencySignSpace := crsAvailable; end; end; FormattedInput.ShowCurrencySign := True; FormattedInput.CurrencySign := FormatSettings.CurrencyString; ThousandSeparator := FormatSettings.ThousandSeparator; DecimalSeparator := FormatSettings.DecimalSeparator; Alignment := taRightJustify;end;procedure Register;begin RegisterComponents('UniAddOns', [TUniCurrencyEdit]);end;end. Quote Link to comment Share on other sites More sharing options...
TuanHoang Posted October 10, 2017 Share Posted October 10, 2017 Thanks. I made a new control that uses the system configuration of currency if anyone is interested. I'm new to controls, so if you see a problem with this let me know. unit UniCurrencyEdit; interface uses SysUtils, Classes, uniGUIBaseClasses, uniGUIClasses, uniEdit; type TUniCurrencyEdit = class(TUniFormattedNumberEdit) private protected { Protected declarations } public constructor Create(AOwner: TComponent); override; published end; procedure Register; implementation constructor TUniCurrencyEdit.Create(AOwner: TComponent); begin inherited; case (formatsettings.CurrencyFormat) of 0: begin FormattedInput.CurrencySignPos := cpsLeft; FormattedInput.CurrencySignSpace := crsNone; end; 1: begin FormattedInput.CurrencySignPos := cpsRight; FormattedInput.CurrencySignSpace := crsNone; end; 2: begin FormattedInput.CurrencySignPos := cpsLeft; FormattedInput.CurrencySignSpace := crsAvailable; end; 3: begin FormattedInput.CurrencySignPos := cpsRight; FormattedInput.CurrencySignSpace := crsAvailable; end; end; FormattedInput.ShowCurrencySign := True; FormattedInput.CurrencySign := FormatSettings.CurrencyString; ThousandSeparator := FormatSettings.ThousandSeparator; DecimalSeparator := FormatSettings.DecimalSeparator; Alignment := taRightJustify; end; procedure Register; begin RegisterComponents('UniAddOns', [TUniCurrencyEdit]); end; end. I think must set DecimalUseOSDefault := True on Create. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.