You've already forked lazarus-ccr
Added: EditFormat property to FloatEdit components
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2834 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -33,6 +33,7 @@ type
|
||||
TJDBLabeledFloatEdit = class(TCustomLabeledEdit)
|
||||
private
|
||||
fFormat: string;
|
||||
fEFormat: string;
|
||||
FDataLink: TFieldDataLink;
|
||||
fDecimales: integer;
|
||||
|
||||
@ -77,6 +78,7 @@ type
|
||||
|
||||
published
|
||||
property DisplayFormat: string read getFormat write setFormat;
|
||||
property EditFormat: string read fEFormat write fEFormat;
|
||||
property DataField: string read GetDataField write SetDataField;
|
||||
property DataSource: TDataSource read GetDataSource write SetDataSource;
|
||||
property Decimals: integer read getDecimals write setDecimals;
|
||||
@ -149,6 +151,9 @@ begin
|
||||
begin
|
||||
if not Focused then
|
||||
formatInput
|
||||
else
|
||||
if Length(EditFormat) > 0 then
|
||||
Caption := FormatFloat(EditFormat, FDataLink.Field.AsFloat)
|
||||
else
|
||||
Caption := FloatToStr(FDataLink.Field.AsFloat);
|
||||
end
|
||||
@ -179,7 +184,10 @@ begin
|
||||
theValue := StrToFloat(Text);
|
||||
if fDecimales > 0 then
|
||||
theValue := ScaleTo(theValue, fDecimales);
|
||||
Text := FloatToStr(theValue);
|
||||
if Length(EditFormat) > 0 then
|
||||
Caption := FormatFloat(EditFormat, theValue)
|
||||
else
|
||||
Caption := FloatToStr(theValue);
|
||||
FDataLink.Field.Value := theValue;
|
||||
end
|
||||
else
|
||||
@ -187,7 +195,10 @@ begin
|
||||
if FDataLink.Field <> nil then
|
||||
begin
|
||||
ShowMessage(Format(SInvalidNumber, [Caption]));
|
||||
Caption := FloatToStr(FDataLink.Field.AsFloat);
|
||||
if Length(EditFormat) > 0 then
|
||||
Caption := FormatFloat(EditFormat, FDataLink.Field.AsFloat)
|
||||
else
|
||||
Caption := FloatToStr(FDataLink.Field.AsFloat);
|
||||
SelectAll;
|
||||
SetFocus;
|
||||
end;
|
||||
@ -356,7 +367,10 @@ begin
|
||||
if not FieldIsEditable(Field) or IsReadOnly then
|
||||
exit;
|
||||
if FDataLink.Field <> nil then
|
||||
Caption := FloatToStr(FDataLink.Field.AsFloat); //FDataLink.Field.AsString;
|
||||
if Length(EditFormat) > 0 then
|
||||
Caption := FormatFloat(EditFormat, FDataLink.Field.AsFloat)
|
||||
else
|
||||
Caption := FloatToStr(FDataLink.Field.AsFloat); //FDataLink.Field.AsString;
|
||||
inherited DoEnter;
|
||||
end;
|
||||
|
||||
@ -369,6 +383,7 @@ begin
|
||||
FDataLink.OnDataChange := @DataChange;
|
||||
FDataLink.OnUpdateData := @UpdateData;
|
||||
FDataLInk.OnActiveChange := @ActiveChange;
|
||||
fEFormat:= '';
|
||||
// Set default values
|
||||
//fDecimales := 2;
|
||||
//fFormat := '0.00';
|
||||
|
@ -34,6 +34,7 @@ type
|
||||
{ Private declarations }
|
||||
theValue: double;
|
||||
fFormat: string;
|
||||
fEFormat: string;
|
||||
fDecimals: integer;
|
||||
function getDecimals: integer;
|
||||
function getFormat: string;
|
||||
@ -58,6 +59,7 @@ type
|
||||
published
|
||||
{ Published declarations }
|
||||
property DisplayFormat: string read getFormat write setFormat;
|
||||
property EditFormat: string read fEFormat write fEFormat;
|
||||
property Decimals: integer read getDecimals write setDecimals;
|
||||
property Value: double read getValue write setValue;
|
||||
|
||||
@ -187,7 +189,10 @@ begin
|
||||
inherited DoEnter;
|
||||
if ReadOnly then
|
||||
exit;
|
||||
Text := FloatToStr(theValue);
|
||||
if Length(EditFormat) > 0 then
|
||||
Text := FormatFloat(EditFormat, theValue)
|
||||
else
|
||||
Text := FloatToStr(theValue);
|
||||
SelectAll;
|
||||
end;
|
||||
|
||||
@ -223,6 +228,7 @@ constructor TJLabeledFloatEdit.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
Text := '';
|
||||
fEFormat := '';
|
||||
fFormat := '#,0.00';
|
||||
fDecimals := 2;
|
||||
formatInput;
|
||||
|
Reference in New Issue
Block a user