TDBPlanner Item Color

Hello, I'm trying to change the Item color dynamically, but nothing happened (DefaultItem colors). I'm trying to do that assigning the item color in function of a field value of my db table.

for i := 0 to DBPlanner1.Items.Count -1 do
  item := DBPlanner1.Items[i];

  idcat := dtmMain.JMSUtl.RetFieldInt('SELECT CategoryID FROM tbactions WHERE ActionID = ' + item.DBKey );

    if idcat = 60 then     
      color := clRed
    else if idcat = 70 then  
      color := clRed
    else if idcat = 80 then
      color := clLime 
      color := clYellow;

    item.Color := color;
    item.ColorTo := color;
    item.CaptionBkg := color;
    item.CaptionBkgTo := color;
    item.TrackColor := color;


This code is recalled each time I change something in the table.

Whats wrong in this code? Is there any property that avoid this?
It seams a trivial problem.

Thank you

I have found the solution!

in DBDaySource1FieldsToItem event I have to insert the code:

like this:

RefreshColors(Item, Fields.FieldByName('CategoryID').Value);

That is indeed the recommended approach for item customization in a TDBPlanner

I'm sure I was wrong somewhere, but the DBMonthSource1FieldsToItem doesn't fire the same event.
Any suggestion?


I checked this but I cannot see evidence that this event is not triggered.
I suggest to set a breakpoint in DBPLANNER.PAS on line 3420
procedure TDBCustomPeriodSource.ReadDBItems(UpdateKey: string);
and see why from this event OnFieldsToItem is possibly not triggered.

ok I will check!