HeaderPane
Main

Compare

A Windows Forms TreeView with columns

The Windows Forms TreeView shows a hierarchy but has no columns. The DataGridView has columns but no hierarchy. Here is how both compare with SftTree/NET 3.0, which has both.

The problem

Sooner or later most Windows Forms applications need to show data that is both hierarchical and tabular: a bill of materials with quantities and prices, a folder tree with sizes and dates, a task list with subtasks, owners and progress. The framework offers two controls, and each one covers half of it.

  • The TreeView shows the hierarchy, but every node is a single label. There are no columns and no column headers.
  • The DataGridView has columns, headers and cell editing, but its rows are flat. There are no levels and no expand/collapse buttons.

The usual workarounds are owner-drawing the TreeView, faking indentation in a DataGridView, or placing two controls side by side and keeping them scrolled in sync. All three are a lot of code to write and to maintain. SftTree/NET 3.0 is a tree control for Windows Forms with grid-like features, written entirely in C#, that does both in one control.

Feature comparison

FeatureTreeViewDataGridViewSftTree/NET 3.0
HierarchyYesNo, flat rowsYes, unlimited levels, single or multiple roots
ColumnsNo, one label per nodeYesYes, resizable and reorderable
Headers and footersNoOne header rowMultiple header rows and footer rows
EditingThe node labelCellsCells, in place, with standard Windows Forms controls
Check boxesOne per nodeIn a check box columnIn any cell, along with radio buttons, buttons and drop-down buttons
Progress bars in cellsNoCustom cell paintingYes
Item heightThe same for every nodePer rowAutomatic, each item as tall as its contents, with word-wrapped text
Cell mergingNoNoYes, vertically and horizontally
SelectionOne nodeRows, columns or cellsItems or individual cells
Row headers, splitter barNoRow headersBoth

What the code looks like

If you know the TreeView, SftTree/NET will look familiar. A node becomes an item, and an item has one cell for each column. This fills a three-column tree with a parent item and a child:

sftTree1.Initializing = true;
sftTree1.Columns.Count = 3;
sftTree1.Headers[0, 0].Text = "Part";
sftTree1.Headers[0, 1].Text = "Quantity";
sftTree1.Headers[0, 2].Text = "Price";

ItemClass assembly = sftTree1.ItemCollection.Add(new string[] { "Front assembly", "1", "249.00" });
ItemClass part = assembly.Add(new string[] { "Bracket", "4", "3.50" });
part.Cells[0].Parts.Add(new CheckBoxPartClass(CheckBoxStateEnum.Checked));

sftTree1.Columns.MakeOptimal(0, false);
sftTree1.Initializing = false;

You can also skip the code: the control is placed from the Visual Studio toolbox, and its property pages let you design columns, items, headers and footers visually.

Modern Windows

SftTree/NET 3.0 runs in .NET Framework 4.7 (or later) and .NET 10 (or later) applications, with Visual Studio designer support in both. It follows the Windows dark mode setting automatically, scales with the DPI of the monitor showing it, honors the Windows contrast themes and has built-in UI Automation support for Narrator, NVDA, JAWS and other screen readers.

When the built-in controls are enough

If all you need is a simple tree of labels, the TreeView is fine, and it is free. The same goes for a flat table and the DataGridView. SftTree/NET earns its place when you need the hierarchy and the columns together, or cells that hold more than text.

Try it

The free trial includes the working control and the C# and VB.NET samples. Test it in your own forms before you buy. A license is royalty-free and includes one year of support and upgrades.

SftTree/NET 3.0 and free trial Documentation