[SOLVED] Using T...Item.Data field to store Integer value lazarus / 31-LCL ---------------------------------------------------------------------- egsuh · 2020-03-02 03:54 I'm seeking advise. Currently I'm using the data field to store integer values. For example, with TTreeNode, ATreeNode.Data := Pointer(AnIntegerValue); IntVar := Integer (ATreeNode.Data); Or with TListItem, AListItem.Data := Pointer(AnIntegerValue); IntVar := Integer (AListItem.Data); I had no difficulty in using this way up to now. But please advise if I have to be careful on anything. ---------------------------------------------------------------------- lucamar · 2020-03-02 10:06 I may be wrong but IIRC you can use it safely in most cases for the standard components, where it's designed exactly for that, but take care when using third-party descendants: they may use it for almost anything. Of course, the only way to be sure is looking into the source to see if the property is being used at all. ---------------------------------------------------------------------- sash · 2020-03-02 10:42 Although pointer and integer (seems to be) safely interchangeable, there are OnCreateNodeClass and OnCreateItemClass for Tree/ListViews correspondingly, so there's much more elegant solution: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TMyNode = class(TTreeNode)    ExtraData1 : integer;    ExtraData2 : single;  end; procedure TForm1.TreeView1CreateNodeClass(Sender : TCustomTreeView; var NodeClass : TTreeNodeClass);begin  NodeClass := TMyNode;end;// use:with TMyNode(SomeNode) do begin  ExtraData1 := 123;  ExtraData2 := 456.789;end; ---------------------------------------------------------------------- egsuh · 2020-03-02 17:03 Quote OnCreateNodeClass and OnCreateItemClass for Tree/ListViews correspondingly, I should have known this at least five years ago.