Changing colour of label in DBCtrlGrid
From: Philip Grace (phil_at_niche-cs.com)
Date: 03/30/04
- Next message: cyx: "How to find the definition of TFontPropterty?"
- Previous message: Philip Grace: "Changing colour of label in DBCtrlGrid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 30 Mar 2004 14:50:26 +0100
Hi,
I have created a component descended from TCustomLabel, based hugely on
TDBText that allows me to change the colour of a label based on the
datafield it's pointing to. I am using this in a DBCtrlGrid and everything
works fine for the general display except that the record currently selected
always sets the colour to the last record displayed on the current page.
When I select a different record the prior record displays the correct
colours.
Essentially my component is the same as TDBText except for the following
function :-
function TFalconDBText.GetFieldText: string;
var
fField : real;
begin
if FDataLink.Field <> nil then begin
fField := FDataLink.Field.AsFloat;
result := format('%.2n', [fField])
if fField = 0 then Font.Color := clBlack;
if fField > 0 then Font.Color := clGreen;
if fField < 0 then begin
Font.Color := clRed;
result := format('(%.2n)', [fField * -1])
end;
end
else
if csDesigning in ComponentState then Result := Name else Result := '';
end;
Does anyone have any idea how to make the colours persist even when a record
in the DBCtrlGrid is highlighted ?
Thanks,
Phil.
- Next message: cyx: "How to find the definition of TFontPropterty?"
- Previous message: Philip Grace: "Changing colour of label in DBCtrlGrid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]