HeaderPane
Main

Compare

An MFC tree control with columns

CTreeCtrl shows a hierarchy but has no columns. CListCtrl has columns but no hierarchy. Here is how both compare with SftTree/DLL 8.0, which has both, for C and C++ applications.

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

FeatureCTreeCtrlCListCtrlSftTree/DLL 8.0
HierarchyYesNo, flat itemsYes, one root or many
ColumnsNo, one label per itemYesYes, resizable and reorderable
Headers and footersNoHeaderHeaders and footers, as titles or buttons with images
In-place editingThe item labelThe first columnAny cell, with standard Windows controls
Multi-line cellsNoNoYes, with automatic word wrap and rows that fit their contents
Cell mergingNoNoYes
SelectionOne itemOne or multiple itemsOne or multiple items
Virtual modeNoYesYes, for large flat lists
Custom cell contentsCustom drawCustom drawOwner-drawn cells and content windows
Splitter barNoNoBuilt 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.

SftTree/DLL 8.0 and free trial Documentation