Recent

Author Topic: TListView with Tree structure  (Read 654 times)

OLLI_S

  • Full Member
  • ***
  • Posts: 111
TListView with Tree structure
« on: March 10, 2019, 12:40:23 am »
Hello,

I am using Lazarus 2.0.0 in Windows 10 Professional x64.

On my form I have a TListView that has 2 columns with static text where the user can select some entries (so Checkboxes is True, ReadOnly is True and also RowSelect is True).
The ViewStyle is vsReport.

I want to group the items in a tree structure.
So I want to add a static headline text and below of the text 2 entries as sub-entries (having 2 columns).
Then there should be a second static headline and below there should be 7 sub-entries.
The sub-entries should be collapsed and expanded (Tree View).

Is that possible with TListView?

Is there a way to display the column headers in bold font?

Best regards

OLLI

lucamar

  • Hero Member
  • *****
  • Posts: 1807
Re: TListView with Tree structure
« Reply #1 on: March 10, 2019, 12:52:46 am »
So I want to add a static headline text and below of the text 2 entries as sub-entries (having 2 columns).
Then there should be a second static headline and below there should be 7 sub-entries.
The sub-entries should be collapsed and expanded (Tree View).

Is that possible with TListView?

I seriously doubt it but ... I tried, I really tried, but I find myself unable to imagine what it is you want it to look like. So, do you have some example pic from other application or something?

Quote from: OLLI_S
Is there a way to display the column headers in bold font?

I don't really know but, maybe with one of the OnCustomDrawXXX or OnAdvancedCustomDrawXXX events?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4 & 2.0.2 w/FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

wp

  • Hero Member
  • *****
  • Posts: 5835
Re: TListView with Tree structure
« Reply #2 on: March 10, 2019, 01:09:14 am »
Is that possible with TListView?

Is there a way to display the column headers in bold font?
Not with TListView. But you should try VirtualTreeView which comes with Lazarus 2.0+ (folder components/VirtualtreeView). It is essentially an advanced treeview but supports multiple columns in addition to the main tree nodes. A lot a formatting options are available. Basic step-by-step instructions for almost exactly your problem can be found at http://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus.
« Last Edit: March 10, 2019, 01:12:02 am by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10