TTreeView with justified child node content (like in grids with cells) lazarus / 31-LCL ---------------------------------------------------------------------- ArminLinder · 2021-04-27 13:19 Hi, what I need is much like the attched example: a treelike structure, with the children at a certain level showing tabular data. As you can see in the sample the programmer took the easy way out and joined all data into one string, which gives an unacceptable look, since within a string he cannot justify the various elements (oh boy, how many times I wished that elements containing text output would support the good old "tab" character). Anyway, is there a ready made component, a sample or a documented solution for this? In this case, "Windows only" will suffice. Thnx, Armin P.S. IMHO a completely different approach would be also possible: take a StringGrid and integrate the tree structure by putting the tree structure into the leftmost rows, and use kind of cell merging mechnism to let the captions write over the cells to the right. Whichever way a component is available, I don't care much. P.P.S. I had a look at VirtualTreeView, which looks promising, but boy, that thing is heavy ... ---------------------------------------------------------------------- balazsszekely · 2021-04-27 14:26 @Nimral If you need a tree with multiple column go with VST.  You can achieve the look from screenshot in 10 minutes or so. Plus it's cross platform. PS: If you need help, just let me know. ---------------------------------------------------------------------- ArminLinder · 2021-04-28 09:17 I remember having tried VST some time ago, and the project barely survived. In general it worked, but was full of little glitches which in total made working with it a pain, and hunting for tipps and fixes ate deeply into the prjoect's time schedule. Are you sure it's worth trying again? if I do, which one on git is the preferred version? The "master", or the lastest "Release Version 5.5.3 - LCL Release 2"? Armin. ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-04-28 10:02 Hey Armin, Quote from: Nimral on April 28, 2021, 11:17:17 amif I do, which one on git is the preferred version? The "master", or the lastest "Release Version 5.5.3 - LCL Release 2"? If you have the OPM(Online Package Manager) installed, it can install a pretty good version of VST and it will allow for further updates once the maintainer of VST grabs GetMem's attention to list a new version Cheers, Gus ---------------------------------------------------------------------- balazsszekely · 2021-04-28 10:31 @Nimral QuoteAre you sure it's worth trying again?Yes, I'm pretty sure that VST is one of the best choice for a multiple column tree. QuoteIn general it worked, but was full of little glitches which in total made working with it a pain, and hunting for tipps and fixes ate deeply into the prjoect's time schedule.The learning curve for VST is steep. You have to decide if the invested time is worth it. Unfortunately I cannot help here. Quoteif I do, which one on git is the preferred version? The "master", or the lastest "Release Version 5.5.3 - LCL Release 2"?Both Lazarus 2.0.12 and Lazarus Trunk have a preinstalled version of VST, a fork of 5.5.3.  As @Gus already mentioned, OPM also contains a VTV, which should be the same with the gitbhub version. PS: If you are unsure, please do a forum search. You will find a lot of examples with VST. ---------------------------------------------------------------------- ArminLinder · 2021-04-28 14:27 Aaaargh. Failed to install VTV via OPM. Please see: https://forum.lazarus.freepascal.org/index.php?topic=54383 .msg403900#msg403900 ---------------------------------------------------------------------- ArminLinder · 2021-04-29 20:52 10 Minutes?  After more than 15 hours, and absolutely no progress, except approx 10 trial projects which have all failed miserably in early stages when I got lost somewhere in one of the many dark corners, and ended up staring at empty or mangled grids with no idea how this could happen since I tried to follow the many tuts and docs around, including the 2613 page monster at https://documentation.help/VirtualTreeview/documentation.pdf I am at the edge of giving up. This damn thing is killing me, exactly like last time when I tried to use it. Alternatives? Armin. ---------------------------------------------------------------------- jamie · 2021-04-29 21:08 why don't you handle the OnCustomDrawItem There are at various other places in custom drawings you can split the line of text so that you can Tab column align your numbers all to the right. Because there you also need to do the graphics. ---------------------------------------------------------------------- ArminLinder · 2021-04-29 23:33 Ok, I need to give up. 1:30 in the morning, and I have been staring at 30 lines of code for 3 hours now, and cannot find out what's wrong. I can add roots. Great, except that only 2 columns get displayed, it should be 4. I can focus and select in column 3 sometimes random text apppears --> I corrupted the memory, somehow. deleting one or more nodes crashes the program adding a child node crashes the program. WTF is going on here? Lazarus 2.0.12 x32 on Windows 10x64, VTV 5.5.3.1 Armin. ---------------------------------------------------------------------- balazsszekely · 2021-04-30 10:00 @Nimral I did a small demo according to the screenshot form the first post. I did try to keep it as simple as possible, sort column is implemented. Please check the attached project(Lazarus 2.0.12/FPC 3.2.0) ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-04-30 15:13 Hey Getmem, Quote from: GetMem on April 30, 2021, 12:00:50 pmPlease check the attached project(Lazarus 2.0.12/FPC 3.2.0) I like your simple approach of one big record for all info. I usually do something like this: 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  TMyNodeType = (ntUnknown, ntType1, ntType2{...});  TCommonAncestor = class(TObject)    FName: String;//<-- Basically for GetNodetext()  end;  TType1 = class(TCommonAncestor)    FTypeOneSpecificField: Integer; //<-- Whateves...  end;  TType2 = class(TCommonAncestor)    FTypeTwoSpecificField: Integer; //<-- Whateves...  end;  PMyNode = ^TMyNode;  TMyNode = record    NodeType: TMyNodeType;    NodeData: TCommonAncestor;  end; OR 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  TMyNodeType = (ntUnknown, ntType1, ntType2{...});  TType1 = class(TObject)    FName: String;//<-- Basically for GetNodetext()    FTypeOneSpecificField: Integer; //<-- Whateves...  end;  TType2 = class(TObject)    FName: String;//<-- Basically for GetNodetext()    FTypeTwoSpecificField: Integer; //<-- Whateves...  end;  PMyNode = ^TMyNode;  TMyNode = record    NodeType: TMyNodeType;    NodeData: TObject;  end; And then type cast according to the MyNode^.NodeType down the code. And the TType1, TType2, etc I get from ORM or from local filesystem. Is this a good approach? Cheers, Gus ---------------------------------------------------------------------- balazsszekely · 2021-05-01 08:15 @Gus QuoteI like your simple approach of one big record for all info.In most cases the nodes tend to be very similar, each has a name, id, parentid, etc. I'm aware that this approach has a small redundancy, but never caused any issues for me. Quote ls this a good approach?  For trees with complex data structure is an excellent idea. ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-05-01 12:05 Hey GetMem, Quote from: GetMem on May 01, 2021, 10:15:41 amIn most cases the nodes tend to be very similar, each has a name, id, parentid, etc. I'm aware that this approach has a small redundancy, but never caused any issues for me. I do concur that for such a simple example and/or data structure the added redundancy is negligible. Quote from: GetMem on May 01, 2021, 10:15:41 amFor trees with complex data structure is an excellent idea. Uffff, thanks for that. I always suffer from loads of imposter syndrome when I come up with something by myself. It's good to have my ideas validated by someone I consider a more senior Pascal dev. Cheers, Gus ---------------------------------------------------------------------- ArminLinder · 2021-05-04 12:58 Just to make this thread complete ... I found the problem. Please see the form definition, somehow the OnCreate event handler slipped from the members section into the public section. This won't, unfortunately, trigger any alarm anywhere, but the FormCreate procedure won't ever be called, TreeNodeSize won't be set properly and a SIGSEV will follow soon. Armin.