From 63f2b8fae4f070c382d64563d8d116b123c421e8 Mon Sep 17 00:00:00 2001 From: jujibo Date: Fri, 22 Nov 2013 09:23:34 +0000 Subject: [PATCH] Added: JDBLabeledIntegerEdit support for null values git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2845 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/jujiboutils/src/jdblabeledintegeredit.pas | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/jujiboutils/src/jdblabeledintegeredit.pas b/components/jujiboutils/src/jdblabeledintegeredit.pas index 3b2957972..2b6a7c8ea 100644 --- a/components/jujiboutils/src/jdblabeledintegeredit.pas +++ b/components/jujiboutils/src/jdblabeledintegeredit.pas @@ -34,6 +34,7 @@ type private fFormat: string; FDataLink: TFieldDataLink; + fNull: boolean; procedure DataChange(Sender: TObject); procedure UpdateData(Sender: TObject); @@ -76,6 +77,7 @@ type property DataField: string read GetDataField write SetDataField; property DataSource: TDataSource read GetDataSource write SetDataSource; property ReadOnly: boolean read GetReadOnly write SetReadOnly default False; + property AllowNull: boolean read fNull write fNull default False; property Action; property Align; @@ -158,6 +160,9 @@ procedure TJDBLabeledIntegerEdit.UpdateData(Sender: TObject); begin if FDataLink.Field <> nil then begin + if fNull and (Length(Caption) = 0) then + FDataLink.Field.Value := Null + else if IsValidInteger(Caption) then begin FDataLink.Field.Text := Text; @@ -218,6 +223,9 @@ procedure TJDBLabeledIntegerEdit.formatInput; begin if FDataLink.Field <> nil then //FDataLink.Field.DisplayText -> formatted (tdbgridcolumns/persistent field DisplayFormat + if FDataLink.Field.IsNull then + Caption := '' + else if fFormat <> '' then Caption := FormatFloat(fFormat, FDataLink.Field.AsInteger) else