From 1bf39713f03519e2dbb8d89b7a6cc191ab14df61 Mon Sep 17 00:00:00 2001 From: alexs75 Date: Mon, 17 Sep 2012 19:52:38 +0000 Subject: [PATCH] RxDBGrid - in TRxCollumn add event - OnDrawCollumnCell. Event fired on draw current cell only git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2514 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/rxdbgrid.pas | 47 ++++++++++++++++++++++---------------- components/rx/rxnew.lpk | 2 +- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/components/rx/rxdbgrid.pas b/components/rx/rxdbgrid.pas index 499e2f3b4..70265b7a8 100644 --- a/components/rx/rxdbgrid.pas +++ b/components/rx/rxdbgrid.pas @@ -362,6 +362,7 @@ type FImageList: TImageList; FKeyList: TStrings; FNotInKeyListIndex: integer; + FOnDrawColumnCell: TDrawColumnCellEvent; function GetFooter: TRxColumnFooter; function GetKeyList: TStrings; procedure SetEditButtons(AValue: TRxColumnEditButtons); @@ -385,6 +386,7 @@ type property Filter: TRxColumnFilter read FFilter write SetFilter; property DirectInput : boolean read FDirectInput write FDirectInput default true; property EditButtons:TRxColumnEditButtons read FEditButtons write SetEditButtons; + property OnDrawColumnCell: TDrawColumnCellEvent read FOnDrawColumnCell write FOnDrawColumnCell; end; { TRxDbGridColumns } @@ -2328,30 +2330,35 @@ begin begin F := GetFieldFromGridColumn(aCol); C := ColumnFromGridColumn(aCol) as TRxColumn; - case ColumnEditorStyle(aCol, F) of - cbsCheckBoxColumn: DrawCheckBoxBitmaps(aCol, aRect, F); - else - if F <> nil then - begin - if F.dataType <> ftBlob then + if Assigned(C.FOnDrawColumnCell) then + C.OnDrawColumnCell(Self, aRect, aCol, TColumn(ColumnFromGridColumn(aCol)), aState) + else + begin + case ColumnEditorStyle(aCol, F) of + cbsCheckBoxColumn: DrawCheckBoxBitmaps(aCol, aRect, F); + else + if F <> nil then begin -{ if Assigned(F.LookupDataSet) and (F.LookupResultField<>'') then - S := F.LookupDataSet.FieldByName(F.LookupResultField).DisplayText - else} - S := F.DisplayText; - if Assigned(C) and (C.KeyList.Count > 0) and (C.PickList.Count > 0) then + if F.dataType <> ftBlob then begin - J := C.KeyList.IndexOf(S); - if (J >= 0) and (J < C.PickList.Count) then - S := C.PickList[j]; - end; + { if Assigned(F.LookupDataSet) and (F.LookupResultField<>'') then + S := F.LookupDataSet.FieldByName(F.LookupResultField).DisplayText + else} + S := F.DisplayText; + if Assigned(C) and (C.KeyList.Count > 0) and (C.PickList.Count > 0) then + begin + J := C.KeyList.IndexOf(S); + if (J >= 0) and (J < C.PickList.Count) then + S := C.PickList[j]; + end; + end + else + S := '(blob)'; end else - S := '(blob)'; - end - else - S := ''; - DrawCellText(aCol, aRow, aRect, aState, S); + S := ''; + DrawCellText(aCol, aRow, aRect, aState, S); + end; end; end; end; diff --git a/components/rx/rxnew.lpk b/components/rx/rxnew.lpk index 534400c6f..ecf0d4db8 100644 --- a/components/rx/rxnew.lpk +++ b/components/rx/rxnew.lpk @@ -26,7 +26,7 @@ Copyright (c) 1998 Master-Bank translate to Lazarus by alexs in 2005 - 2012 "/> - +