TdxDbOrgChart.OnNewKey Event
OnNewKey occurs when a new key value is required.
Declaration
property OnNewKey: TdxOcNewKeyEvent read; write;
Remarks
Called in all cases when it is required to create a new key: on adding new nodes, and also on changing the tree structure by Add… Insert and MoveTo methods. The event handler must assign to a KeyValue a variable value bigger than of MaxValue. New keys are created automatically if the KeyField is an integer type. In this case to define the OnNewKey event handler is not required. If the KeyField type differs from an integer (for example string), the OnNewKey event handler must be defined.
procedure TForm1.ChartNewKey(Sender: TObject; MaxValue: Variant;
var KeyValue: Variant);
begin
if VarIsNull(MaxValue) then KeyValue := '00000000'
else begin
KeyValue := IntToStr(StrToInt(MaxValue) + 1);
while Length(KeyValue) < 8 do KeyValue := '0' + KeyValue;
end;
end;
See Also