You've already forked lazarus-ccr
Added EditFormat property to JDBGridControl
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2835 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -33,6 +33,7 @@ type
|
|||||||
private
|
private
|
||||||
fDecimals: integer;
|
fDecimals: integer;
|
||||||
fMaxLength: integer;
|
fMaxLength: integer;
|
||||||
|
fEFormat: string;
|
||||||
function getDecimals: integer;
|
function getDecimals: integer;
|
||||||
function getMaxLength: integer;
|
function getMaxLength: integer;
|
||||||
procedure setDecimals(AValue: integer);
|
procedure setDecimals(AValue: integer);
|
||||||
@@ -40,6 +41,7 @@ type
|
|||||||
published
|
published
|
||||||
property Decimals: integer read getDecimals write setDecimals;
|
property Decimals: integer read getDecimals write setDecimals;
|
||||||
property MaxLength: integer read getMaxLength write setMaxLength;
|
property MaxLength: integer read getMaxLength write setMaxLength;
|
||||||
|
property EditFormat: string read fEFormat write fEFormat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TJDBGridColumns }
|
{ TJDBGridColumns }
|
||||||
@@ -179,9 +181,11 @@ begin
|
|||||||
Result := dateTimeDbGridControl.Editor(Self);
|
Result := dateTimeDbGridControl.Editor(Self);
|
||||||
ftCurrency, ftFloat:
|
ftCurrency, ftFloat:
|
||||||
Result :=
|
Result :=
|
||||||
doubleDbGridControl.Editor(Self, Columns[Column - 1].Decimals);
|
doubleDbGridControl.Editor(Self, Columns[Column - 1].Decimals,
|
||||||
|
Columns[Column - 1].EditFormat);
|
||||||
ftBCD, ftFMTBCD:
|
ftBCD, ftFMTBCD:
|
||||||
Result := doubleDbGridControl.Editor(Self, aField.Size);
|
Result := doubleDbGridControl.Editor(Self, aField.Size,
|
||||||
|
Columns[Column - 1].EditFormat);
|
||||||
ftString:
|
ftString:
|
||||||
Result := stringDbGridControl.Editor(Self, Columns[Column - 1].MaxLength);
|
Result := stringDbGridControl.Editor(Self, Columns[Column - 1].MaxLength);
|
||||||
end;
|
end;
|
||||||
@@ -235,4 +239,3 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@@ -163,6 +163,7 @@ type
|
|||||||
updated: boolean;
|
updated: boolean;
|
||||||
theValue: double;
|
theValue: double;
|
||||||
fDecimals: integer;
|
fDecimals: integer;
|
||||||
|
fEFormat: string;
|
||||||
function getDecimals: integer;
|
function getDecimals: integer;
|
||||||
procedure myEditOnEnter(Sender: TObject);
|
procedure myEditOnEnter(Sender: TObject);
|
||||||
procedure myEditOnEditingDone(Sender: TObject);
|
procedure myEditOnEditingDone(Sender: TObject);
|
||||||
@@ -177,7 +178,8 @@ type
|
|||||||
property decimals: integer read getDecimals write setDecimals;
|
property decimals: integer read getDecimals write setDecimals;
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function Editor(aGrid: TDBGrid; aDecimals: integer = 2): TStringCellEditor;
|
function Editor(aGrid: TDBGrid; aDecimals: integer = 2;
|
||||||
|
aEFormat: string = ''): TStringCellEditor;
|
||||||
function CanDefocus: boolean;
|
function CanDefocus: boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -290,8 +292,8 @@ begin
|
|||||||
if Field.IsNull then
|
if Field.IsNull then
|
||||||
Result := ''
|
Result := ''
|
||||||
else
|
else
|
||||||
Result := FormatDateTime(ShortDateFormat, Field.AsDateTime) + ' ' +
|
Result := FormatDateTime(ShortDateFormat, Field.AsDateTime) +
|
||||||
FormatDateTime(ShortTimeFormat, Field.AsDateTime);
|
' ' + FormatDateTime(ShortTimeFormat, Field.AsDateTime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJDbGridDateTimeCtrl.myEditEnter(Sender: TObject);
|
procedure TJDbGridDateTimeCtrl.myEditEnter(Sender: TObject);
|
||||||
@@ -950,7 +952,10 @@ begin
|
|||||||
if not Assigned(Field) then
|
if not Assigned(Field) then
|
||||||
Abort;
|
Abort;
|
||||||
CellEditor.BoundsRect := theGrid.SelectedFieldRect;
|
CellEditor.BoundsRect := theGrid.SelectedFieldRect;
|
||||||
CellEditor.Text := Field.AsString;
|
if Length(fEFormat) > 0 then
|
||||||
|
CellEditor.Text := FormatFloat(fEFormat, Field.AsFloat)
|
||||||
|
else
|
||||||
|
CellEditor.Text := Field.AsString;
|
||||||
CellEditor.OnKeyPress := @OnKeyPress; // Recuperamos el control :-p
|
CellEditor.OnKeyPress := @OnKeyPress; // Recuperamos el control :-p
|
||||||
CellEditor.OnKeyDown := @OnKeyDown;
|
CellEditor.OnKeyDown := @OnKeyDown;
|
||||||
theValue := Field.AsFloat;
|
theValue := Field.AsFloat;
|
||||||
@@ -1075,10 +1080,11 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TJDbGridDoubleCtrl.Editor(aGrid: TDBGrid;
|
function TJDbGridDoubleCtrl.Editor(aGrid: TDBGrid; aDecimals: integer;
|
||||||
aDecimals: integer): TStringCellEditor;
|
aEFormat: string): TStringCellEditor;
|
||||||
begin
|
begin
|
||||||
decimals := aDecimals;
|
decimals := aDecimals;
|
||||||
|
fEFormat := aEFormat;
|
||||||
theGrid := aGrid;
|
theGrid := aGrid;
|
||||||
Result := CellEditor;
|
Result := CellEditor;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user