Delphi - change text color based on current record value
Posted
by
Welliam
on Stack Overflow
See other posts from Stack Overflow
or by Welliam
Published on 2012-09-12T03:36:47Z
Indexed on
2012/09/12
3:37 UTC
Read the original article
Hit count: 104
using db controls connected to a FireBird database. and I have a simple dblabel I want to change text color based on current value for current record
The user navigate using the dbnavigator and I wrote code in the navigator button click. but there is a problem the code always read the previous record value not the current one so the color is wrong !! for example:
procedure <navigator button click>;
begin
if table1.FieldByName('field1').AsString = 'val1' then
<dblabel.textcolor> := red
else
<dblabel.textcolor> := green;
end;
but as I said the value is one record behind. why is that and what is the best approach to change label text color ?
Thanks
© Stack Overflow or respective owner