The problem
Files nest inside folders, tasks roll up into projects, accounts branch into sub-accounts, and each of them has values that belong in columns. The Windows common controls, and the MFC classes that wrap them, each cover half of it.
- CTreeCtrl (the tree-view control) shows the hierarchy, but every item is a single label. There are no columns and no column header.
- CListCtrl (the list-view control) in report view has columns and a header, but its items are flat. There are no levels and no expand/collapse buttons.
The usual workarounds are custom draw in a tree-view, a list-view with faked indentation, or a tree and a list side by side kept scrolled in sync. SftTree/DLL 8.0 is a DLL-based tree control for C, C++ and MFC that presents hierarchical, multi-column data in one control.
Feature comparison
| Feature | CTreeCtrl | CListCtrl | SftTree/DLL 8.0 |
|---|---|---|---|
| Hierarchy | Yes | No, flat items | Yes, one root or many |
| Columns | No, one label per item | Yes | Yes, resizable and reorderable |
| Headers and footers | No | Header | Headers and footers, as titles or buttons with images |
| In-place editing | The item label | The first column | Any cell, with standard Windows controls |
| Multi-line cells | No | No | Yes, with automatic word wrap and rows that fit their contents |
| Cell merging | No | No | Yes |
| Selection | One item | One or multiple items | One or multiple items |
| Virtual mode | No | Yes | Yes, for large flat lists |
| Custom cell contents | Custom draw | Custom draw | Owner-drawn cells and content windows |
| Splitter bar | No | No | Built in |
What the code looks like
Items are added in display order and each one gets a level. This fills a three-column tree with a parent item and a child:
int index;
SftTree_SetShowHeader(hwndTree, TRUE);
SftTree_SetColumnsEx(hwndTree, 3, aCol); /* column widths and attributes */
index = SftTree_AddString(hwndTree, TEXT("Front assembly"));
SftTree_SetTextCol(hwndTree, index, 1, TEXT("1"));
SftTree_SetTextCol(hwndTree, index, 2, TEXT("249.00"));
index = SftTree_AddString(hwndTree, TEXT("Bracket"));
SftTree_SetItemLevel(hwndTree, index, 1);
SftTree_SetTextCol(hwndTree, index, 1, TEXT("4"));
SftTree_SetTextCol(hwndTree, index, 2, TEXT("3.50"));
MFC applications use the supplied C++ classes, which come with source code: m_Tree.AddString(...), m_Tree.SetItemLevel(index, 1). The product includes samples for C and for MFC, and an API reference written for AI coding assistants.
Modern Windows
SftTree/DLL 8.0 supports 32-bit and 64-bit applications on Intel and ARM64 applications on Windows 11, with UNICODE on every platform. It follows the Windows light/dark setting automatically, supports Per-Monitor v2 DPI scaling, Windows High Contrast and right-to-left reading, and has a built-in UI Automation provider for Narrator, NVDA, JAWS and other screen readers.
When the common controls are enough
If all you need is a tree of labels, CTreeCtrl is fine, and it is part of Windows. The same goes for a flat table and CListCtrl. SftTree/DLL earns its place when you need the hierarchy and the columns together, cells that hold more than a line of text, or editing in any cell.
Try it
Download the free trial and test it in your own application before you buy. A license is royalty-free in run-time mode and includes one year of support and upgrades.
