Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxDbOrgChart.OnNewKey Event

In This Article

OnNewKey occurs when a new key value is required.

#Declaration

Delphi
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