views:

411

answers:

2

I am using a TVirtualStringTree (part of the Virtual TreeView Component) in my Delphi project and I would like to create a view where 2 columns can have children that are expandable/collapsable with [+] sign. In the picture below as sample I would like to have a [+] sign in the Server Column but also in the Image column. The idea is that the tree has several Server nodes that each have many process child's (which main colum is image) and some processes have sub-processes which are children of the processes'node.

alt text

Is such a layout possible? If not with the default component I would appreciate advice on how to implement this in a descendant.

/Edit: The following screenshots are when using the method TOndrej suggests: alt text alt text alt text

OK, I decided to implement as per TOndrej's idea: alt text

+4  A: 

You most probably don't need that. Just make yourself a clear specification of what grouping you need. The first column can be multi-purpose - showing different information on each grouping level - e.g. level 0: server, level 1: process, level 2 and higher: child process. On each level, only columns relevant to that level need to display any information. In the above example, level 0 would only display the server name in the first column; the rest of the columns would remain empty.

You could probably implement as many plus signs as you want by custom-drawing but it would be a lot of work and I really think the result is unnecessary, unusual and easily confusing to the user.

TOndrej
I had already thought about that but it looks a little weird (I added 2 more screenshots) both when I repeat the servername and leave it out.
Remko
Remko, it only looks weird because you didn't do what Tondrej suggested. *Merge* the "server" and "image" columns into one. For server objects, that column's text will hold server names; for processes, it will show file names. Your third version looks closest; the server nodes aren't using any of the rest of the columns, anyway.
Rob Kennedy
@TOndrej: OK I opted for your solution, see last screenshot (and with the correct images it looks much better). +1@Rob Kennedy: thanks for the extra comment, guess I was thinking way too difficult. +1PS: I have to test what this approach means for sorting (obvious) and searching in the tree ( I implemented auto-search by typing the first letter(s) )
Remko
+3  A: 

Only one column can have the tree, the other columns act a a listview. The column with the tree is the main column.

I would not know how your grouping would work if two columns had a tree and they might "conflict". What is parent node etc etc. GUI technically this might not be the best way of giving those details; a user won't expect it to work that way.

Ritsaert Hornstra
Given what I would like to show, what would be a logical way for you?
Remko
I think you only need one tree column with on the top level the server nodes, and beneath those the process nodes (and beneath those the process nodes recursion for sub processes). If you want to show the correct images you need to make nodes of a specified "Kind" eg a server kind, a process kind etc etc. Some columns will only be filled for servers, others only for processes etc etc.
Ritsaert Hornstra
+1, I accepted TOndrej's answer as he was first.
Remko