Create own Planner Item Editor?


is there an example how I can create an own Editor? Did I have to compile/install the tmsd2010.dpk new to add an Item Editor?


Please see the samples

TSimpleItemEditor, TPeriodItemEditor

This class is the interface between the PlannerItem and your custom form you can use to edit:

  TSimpleItemEditor = class(TCustomItemEditor)
    FEditForm: TSimplePlannerItemEditForm;
    FCenter: Boolean;
    FFormLeft: Integer;
    FFormTop: Integer;
    constructor Create(AOwner: TComponent); override;
    procedure CreateEditor(AOwner: TComponent); override;
    procedure DestroyEditor; override;
    function Execute: Integer; override;
    procedure PlannerItemToEdit(APlannerItem: TPlannerItem); override;
    procedure EditToPlannerItem(APlannerItem: TPlannerItem); override;
    property CenterOnScreen: Boolean read FCenter write FCenter default True;
    property FormLeft: Integer read FFormLeft write FFormLeft;
    property FormTop: Integer read FFormTop write FFormTop;

If you implement an override the public methods, you can use any custom form as inplace editor (similar to samples PlanSimpleEdit.pas, PlanPeriodEdit.pas)


thanks for your answer. I've done so, but I got one last question: how can I register MyEditForm to the Planner?

Best regards ...

The Execute method of your editor class is responsible for creating & showing your form.
If you descend from TCustomItemEditor, you can assign this class to PlannerItem.Editor


ok. Executing works, but now I got another problem. If I use my Editor, the Item is not updated (If I use no Editor it works correct). My Editor is like the code in #2. The changes of an item are displayed in the item, but there's no update to the database? I register the Editor like:

    ScheduleEditor : TSimpleItemEditor;
  // OnCreate
  ScheduleEditor := TSimpleItemEditor.Create(self);
  planner.DefaultItem.Editor := ScheduleEditor;

Best regards ....

Did you implement the override of the method:

procedure EditToPlannerItem(APlannerItem: TPlannerItem); override;

this is responsible for updating the item after editing.


yes, it looks:

procedure TSimpleItemEditor.EditToPlannerItem(APlannerItem: TPlannerItem);


procedure Tdateedit.AssignToPlannerItem(PlannerItem: TPlannerItem);
  PlannerItem.CaptionText       := edSubject.Text;
  PlannerItem.Text              := TStringList(edMemo.Lines);
  PlannerItem.ItemStartTime     := Int(PlanDate.Date) + Frac(StartTime.Time);
  PlannerItem.ItemEndTime       := Int(PlanDate.Date) + Frac(EndTime.Time);
  PlannerItem.ItemRealStartTime := Int(PlanDate.Date) + Frac(StartTime.Time);
  PlannerItem.ItemRealEndTime   := Int(PlanDate.Date) + Frac(EndTime.Time);

and this works, but only to the item. Not to the database!

If I drag and drop the item without using an editor changes to the database are made.

Best regards ...

Call Item.Update after setting the properties.


that was simple :-) . Great!

Best regards ...