Property UserData

Last Updated: 5/12/2009



Sections above here:
Home  »  Class Reference  »  TIWTreeView

Sections below here:

    Topics in this section:
    Property UserData
    Property CSS
    Event OnPlusMinus
    Property DoServerSidePlusMinus
    ScrollToName
    TIWTreeViewItems.Add
    Code Samples

    Search Documentation:

    Property UserData: TObject

    This is a TObject that you can put any data into.  This UserData object is freed with the TreeViewItem.

    e.g.:

    type

      TNodeUserData = class
        NodeLevel: Integer;
        DetailLoaded: Boolean;
        RecordKey: Variant;
      end;

    Creating an object of type TNodeUserData

      TreeNode.UserData := TNodeUserData.Create;
      TNodeUserData(TreeNode.UserData).NodeLevel := NodeLevel;

      TNodeUserData(TreeNode.UserData).DetailLoaded := False;
      TNodeUserData(TreeNode.UserData).RecordKey := Dataset.FieldByName(KeyField).Value;

    Using the data stored the property UserData:

    procedure TfrmTreeView.TreeViewTreeItemClick(Sender: TObject; ATreeViewItem: TIWTreeViewItem);
    var
      LNodeLevel: Integer;
      LRecordKey: Variant;

    begin
      if not TNodeUserData(ATreeViewItem.UserData).DetailLoaded then begin
        LNodeLevel :=
    TNodeUserData(ATreeViewItem.UserData).NodeLevel;
        LRecordKey := TNodeUserData(ATreeViewItem.UserData).RecordKey;
        LoadDetailForNode(LNodeLevel, LRecordKey);
      end;

    end;







    (C) 2002-2009 - Atozed Software Ltd.